using Marco.Pms.Model.Dtos.Project;
using Marco.Pms.Model.Projects;
using Marco.Pms.Model.ViewModels.Projects;

namespace Marco.Pms.Model.Mapper
{
    public static class ProjectMapper
    {
        public static ProjectDto ToProjectDto(this Project projectModel)
        {
            return new ProjectDto
            {
                Id = projectModel.Id,
                ContactPerson = projectModel.ContactPerson,
                ProjectAddress = projectModel.ProjectAddress,
                Name = projectModel.Name,
                ShortName = projectModel.ShortName,
                EndDate = projectModel.EndDate,
                StartDate = projectModel.StartDate,
                ProjectStatusId = projectModel.ProjectStatusId
            };
        }

        public static Project ToProjectFromCreateProjectDto(this CreateProjectDto projectModel, Guid TenantId)
        {
            return new Project
            {
                ContactPerson = projectModel.ContactPerson ?? "",
                ProjectAddress = projectModel.ProjectAddress ?? "",
                Name = projectModel.Name ?? "",
                ShortName = projectModel.ShortName,
                EndDate = projectModel.EndDate,
                StartDate = projectModel.StartDate,
                TenantId = TenantId,
                ProjectStatusId = projectModel.ProjectStatusId
            };
        }

        public static Project ToProjectFromUpdateProjectDto(this UpdateProjectDto projectModel, Guid TenantId, Guid id)
        {
            return new Project
            {
                Id = id,
                ContactPerson = projectModel.ContactPerson ?? "",
                ProjectAddress = projectModel.ProjectAddress ?? "",
                Name = projectModel.Name ?? "",
                ShortName = projectModel.ShortName,
                EndDate = projectModel.EndDate,
                StartDate = projectModel.StartDate,
                TenantId = TenantId,
                ProjectStatusId = projectModel.ProjectStatusId
            };
        }

        public static ProjectAllocation ToProjectAllocationFromProjectAllocationDto(this ProjectAllocationDot model, Guid TenantId)
        {
            return new ProjectAllocation
            {
                AllocationDate = DateTime.Now,
                EmployeeId = model.EmployeeId,
                JobRoleId = model.JobRoleId,
                TenantId = TenantId,
                ProjectId = model.ProjectId
            };
        }


        public static ProjectAllocation ToProjectAllocationFromProjectsAllocationDto(this ProjectsAllocationDto model, Guid TenantId, Guid employeeId)
        {
            return new ProjectAllocation
            {
                AllocationDate = DateTime.Now,
                EmployeeId = employeeId,
                JobRoleId = model.JobRoleId,
                TenantId = TenantId,
                ProjectId = model.ProjectId
            };
        }

        public static ProjectListVM ToProjectListVMFromProject(this Project project)
        {
            return new ProjectListVM
            {
                Id = project.Id,
                Name = project.Name,
                ShortName = project.ShortName,
                ProjectAddress = project.ProjectAddress,
                ProjectStatusId = project.ProjectStatusId,
                ContactPerson = project.ContactPerson,
                StartDate = project.StartDate,
                EndDate = project.EndDate,
            };
        }
        public static ProjectInfoVM ToProjectInfoVMFromProject(this Project project)
        {
            return new ProjectInfoVM
            {
                Id = project.Id,
                Name = project.Name,
                ShortName = project.ShortName,
                ProjectAddress = project.ProjectAddress,
                ProjectStatusId = project.ProjectStatusId,
                ContactPerson = project.ContactPerson,
                StartDate = project.StartDate,
                EndDate = project.EndDate,
            };
        }
    }
}
