2023-05-17 16:00:50 +10:00
|
|
|
|
using AutoMapper;
|
2025-09-11 16:03:51 +10:00
|
|
|
|
using PARR.API.Contracts.V1.Requests;
|
2023-06-16 15:00:11 +10:00
|
|
|
|
using PARR.API.Contracts.V1.Requests.Queries;
|
2026-04-14 09:56:31 +10:00
|
|
|
|
using PARR.Domain.Common.Pagination;
|
2026-07-16 10:12:56 +10:00
|
|
|
|
using PARR.Domain.DTOs.RobotMetrics;
|
2026-06-11 11:40:12 +10:00
|
|
|
|
using PARR.Domain.DTOs.RobotSnapshotDTO;
|
2026-07-03 11:17:48 +10:00
|
|
|
|
using PARR.Domain.Entities.JobEntities;
|
2023-05-17 16:00:50 +10:00
|
|
|
|
|
2023-05-17 16:30:13 +10:00
|
|
|
|
namespace PARR.API.MappingProfiles
|
2023-05-17 16:00:50 +10:00
|
|
|
|
{
|
|
|
|
|
|
public class RequestToDomainProfile : Profile
|
|
|
|
|
|
{
|
|
|
|
|
|
public RequestToDomainProfile()
|
|
|
|
|
|
{
|
2023-06-16 15:00:11 +10:00
|
|
|
|
CreateMap<PaginationQuery, PaginationFilter>();
|
2025-09-11 16:03:51 +10:00
|
|
|
|
|
2025-09-16 15:27:26 +10:00
|
|
|
|
#region Job
|
2025-12-08 14:23:08 +10:00
|
|
|
|
|
2025-09-11 16:03:51 +10:00
|
|
|
|
CreateMap<JobRequest, Job>()
|
|
|
|
|
|
.ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid()))
|
2026-06-19 11:19:43 +10:00
|
|
|
|
.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))
|
2025-09-11 16:03:51 +10:00
|
|
|
|
.ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow))
|
2026-06-30 16:12:52 +10:00
|
|
|
|
.ForMember(d => d.AutoControl, o => o.Ignore())
|
2025-09-11 16:03:51 +10:00
|
|
|
|
.AfterMap((s, d) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (d.UnitFilters != null)
|
|
|
|
|
|
foreach (var unitFilter in d.UnitFilters)
|
|
|
|
|
|
unitFilter.JobId = d.Id;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<UnitFilterRequest, JobUnitFilter>()
|
|
|
|
|
|
.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;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-09-22 15:25:17 +10:00
|
|
|
|
CreateMap<FieldFilterRequest, JobFieldFilter>()
|
2025-09-11 16:03:51 +10:00
|
|
|
|
.ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid()))
|
|
|
|
|
|
.ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow));
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<RelationshipFilterRequest, JobRelationshipFilter>();
|
2025-12-08 14:23:08 +10:00
|
|
|
|
|
2025-09-16 15:27:26 +10:00
|
|
|
|
#endregion
|
2026-06-11 11:40:12 +10:00
|
|
|
|
|
|
|
|
|
|
CreateMap<StatRobotSnapshotQuery, RobotSnapshotQuery>();
|
2026-07-16 10:12:56 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<RobotFilteredMetricsQuery, MetricFilter>();
|
2023-05-17 16:00:50 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|