feat(api): JobControl переписан метод Create+Валидация
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using AutoMapper;
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models.Job;
|
||||
|
||||
namespace PARR.API.MappingProfiles
|
||||
{
|
||||
@@ -9,6 +11,37 @@ namespace PARR.API.MappingProfiles
|
||||
public RequestToDomainProfile()
|
||||
{
|
||||
CreateMap<PaginationQuery, PaginationFilter>();
|
||||
|
||||
CreateMap<JobRequest, Job>()
|
||||
.ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid()))
|
||||
.ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow))
|
||||
.AfterMap((s, d) =>
|
||||
{
|
||||
if (d.UnitFilters != null)
|
||||
foreach (var unitFilter in d.UnitFilters)
|
||||
unitFilter.JobId = d.Id;
|
||||
});
|
||||
|
||||
CreateMap<UnitFilterRequest, JobUnitFilter>()
|
||||
.ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid()))
|
||||
.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<FieldFilterRequest, FieldFilter>()
|
||||
.ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid()))
|
||||
.ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow));
|
||||
|
||||
CreateMap<RelationshipFilterRequest, JobRelationshipFilter>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user