115 lines
4.9 KiB
C#
115 lines
4.9 KiB
C#
using AutoMapper;
|
|
using Marco.Pms.Model.Dtos.Project;
|
|
using Marco.Pms.Model.Dtos.Tenant;
|
|
using Marco.Pms.Model.Employees;
|
|
using Marco.Pms.Model.Master;
|
|
using Marco.Pms.Model.MongoDBModels;
|
|
using Marco.Pms.Model.Projects;
|
|
using Marco.Pms.Model.TenantModel;
|
|
using Marco.Pms.Model.TenantModels;
|
|
using Marco.Pms.Model.TenantModels.MongoDBModel;
|
|
using Marco.Pms.Model.ViewModels.Activities;
|
|
using Marco.Pms.Model.ViewModels.Employee;
|
|
using Marco.Pms.Model.ViewModels.Projects;
|
|
using Marco.Pms.Model.ViewModels.Tenant;
|
|
|
|
namespace Marco.Pms.Services.MappingProfiles
|
|
{
|
|
public class MappingProfile : Profile
|
|
{
|
|
public MappingProfile()
|
|
{
|
|
#region ======================================================= Tenant =======================================================
|
|
CreateMap<Tenant, TenantVM>();
|
|
CreateMap<Tenant, TenantListVM>();
|
|
CreateMap<Tenant, TenantDetailsVM>();
|
|
|
|
CreateMap<CreateTenantDto, Tenant>()
|
|
.ForMember(
|
|
dest => dest.ContactName,
|
|
opt => opt.MapFrom(src => $"{src.FirstName} {src.LastName}")
|
|
)
|
|
.ForMember(
|
|
dest => dest.Name,
|
|
opt => opt.MapFrom(src => src.OrganizationName)
|
|
);
|
|
|
|
CreateMap<SubscriptionPlanDetails, SubscriptionPlanVM>()
|
|
.ForMember(
|
|
dest => dest.PlanName,
|
|
opt => opt.MapFrom(src => src.Plan != null ? src.Plan.PlanName : "")
|
|
)
|
|
.ForMember(
|
|
dest => dest.Description,
|
|
opt => opt.MapFrom(src => src.Plan != null ? src.Plan.Description : "")
|
|
);
|
|
CreateMap<SubscriptionPlanDetailsDto, SubscriptionPlanDetails>();
|
|
CreateMap<SubscriptionPlanDto, SubscriptionPlan>();
|
|
|
|
CreateMap<FeatureDetailsDto, FeatureDetails>();
|
|
CreateMap<SubscriptionCheckListDto, SubscriptionCheckList>();
|
|
CreateMap<SupportDetailsDto, SupportDetails>();
|
|
CreateMap<ReportDetailsDto, ReportDetails>();
|
|
CreateMap<ModulesDetailsDto, ModulesDetails>();
|
|
CreateMap<ProjectManagementDetailsDto, ProjectManagementDetails>();
|
|
CreateMap<AttendanceDetailsDto, AttendanceDetails>();
|
|
CreateMap<DirectoryDetailsDto, DirectoryDetails>();
|
|
CreateMap<ExpenseModuleDetailsDto, ExpenseModuleDetails>();
|
|
|
|
#endregion
|
|
|
|
#region ======================================================= Projects =======================================================
|
|
// Your mappings
|
|
CreateMap<Project, ProjectVM>();
|
|
CreateMap<Project, ProjectInfoVM>();
|
|
CreateMap<ProjectMongoDB, ProjectInfoVM>();
|
|
CreateMap<UpdateProjectDto, Project>();
|
|
CreateMap<Project, ProjectListVM>();
|
|
CreateMap<Project, ProjectDto>();
|
|
CreateMap<ProjectMongoDB, ProjectListVM>();
|
|
CreateMap<ProjectMongoDB, ProjectVM>()
|
|
.ForMember(
|
|
dest => dest.Id,
|
|
// Explicitly and safely convert string Id to Guid Id
|
|
opt => opt.MapFrom(src => new Guid(src.Id))
|
|
);
|
|
|
|
CreateMap<ProjectMongoDB, Project>()
|
|
.ForMember(
|
|
dest => dest.Id,
|
|
// Explicitly and safely convert string Id to Guid Id
|
|
opt => opt.MapFrom(src => new Guid(src.Id))
|
|
).ForMember(
|
|
dest => dest.ProjectStatusId,
|
|
// Explicitly and safely convert string ProjectStatusId to Guid ProjectStatusId
|
|
opt => opt.MapFrom(src => src.ProjectStatus == null ? Guid.Empty : new Guid(src.ProjectStatus.Id))
|
|
);
|
|
|
|
CreateMap<StatusMasterMongoDB, StatusMaster>();
|
|
CreateMap<ProjectVM, Project>();
|
|
CreateMap<CreateProjectDto, Project>();
|
|
CreateMap<ProjectAllocationDot, ProjectAllocation>()
|
|
.ForMember(
|
|
dest => dest.EmployeeId,
|
|
// Explicitly and safely convert string ProjectStatusId to Guid ProjectStatusId
|
|
opt => opt.MapFrom(src => src.EmpID));
|
|
CreateMap<ProjectsAllocationDto, ProjectAllocation>();
|
|
CreateMap<ProjectAllocation, ProjectAllocationVM>();
|
|
|
|
CreateMap<BuildingDto, Building>();
|
|
CreateMap<FloorDto, Floor>();
|
|
CreateMap<WorkAreaDto, WorkArea>();
|
|
CreateMap<WorkItemDto, WorkItem>()
|
|
.ForMember(
|
|
dest => dest.Description,
|
|
opt => opt.MapFrom(src => src.Comment));
|
|
#endregion
|
|
|
|
#region ======================================================= Employees =======================================================
|
|
CreateMap<Employee, EmployeeVM>();
|
|
CreateMap<Employee, BasicEmployeeVM>();
|
|
#endregion
|
|
}
|
|
}
|
|
}
|