using AutoMapper; using PARR.API.Contracts.V1.Requests; using PARR.API.Contracts.V1.Requests.Queries; using PARR.Domain.Common.Pagination; using PARR.Domain.DTOs.RobotMetrics; using PARR.Domain.DTOs.RobotSnapshotDTO; using PARR.Domain.Entities.JobEntities; namespace PARR.API.MappingProfiles { public class RequestToDomainProfile : Profile { public RequestToDomainProfile() { CreateMap(); #region Job CreateMap() .ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid())) .ForMember(d => d.IsParentRelationships, o => o.MapFrom(s => s.Relationships != null ? s.Relationships.IsParentRelationships : (bool?)null)) .ForMember(d => d.MaxValueRelationships, o => o.MapFrom(s => s.Relationships != null ? s.Relationships.MaxValueRelationships : (int?)null)) .ForMember(d => d.MinValueRelationships, o => o.MapFrom(s => s.Relationships != null ? s.Relationships.MinValueRelationships : (int?)null)) .ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow)) .ForMember(d => d.AutoControl, o => o.Ignore()) .AfterMap((s, d) => { if (d.UnitFilters != null) foreach (var unitFilter in d.UnitFilters) unitFilter.JobId = d.Id; }); CreateMap() .ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow)) .ForMember(d => d.UnitFilter, o => o.MapFrom(s => s.UnitFilterMask)) .AfterMap((s, d) => { if (d.FieldFilters != null) foreach (var fieldFilter in d.FieldFilters) fieldFilter.UnitFilterId = d.Id; if (d.RelationshipFilters != null) foreach (var relationshipFilter in d.RelationshipFilters) relationshipFilter.UnitFilterId = d.Id; }); CreateMap() .ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid())) .ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow)); CreateMap(); #endregion CreateMap(); CreateMap(); } } }