using AutoMapper; using Marco.Pms.Model.Dtos.Project; using Marco.Pms.Model.Master; using Marco.Pms.Model.MongoDBModels; using Marco.Pms.Model.Projects; using Marco.Pms.Model.ViewModels.Projects; namespace Marco.Pms.Services.MappingProfiles { public class ProjectMappingProfile : Profile { public ProjectMappingProfile() { // Your mappings CreateMap(); CreateMap(); CreateMap(); CreateMap(); CreateMap(); CreateMap(); CreateMap(); CreateMap() .ForMember( dest => dest.Id, // Explicitly and safely convert string Id to Guid Id opt => opt.MapFrom(src => new Guid(src.Id)) ); CreateMap() .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(); CreateMap(); CreateMap(); } } }