-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFlexApplicationAutoMapperProfile.cs
More file actions
49 lines (43 loc) · 2.28 KB
/
FlexApplicationAutoMapperProfile.cs
File metadata and controls
49 lines (43 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using AutoMapper;
using System.Linq;
using Unity.Flex.Domain.ScoresheetInstances;
using Unity.Flex.Domain.Scoresheets;
using Unity.Flex.Domain.WorksheetInstances;
using Unity.Flex.Domain.WorksheetLinks;
using Unity.Flex.Domain.Worksheets;
using Unity.Flex.Scoresheets;
using Unity.Flex.WorksheetInstances;
using Unity.Flex.WorksheetLinks;
using Unity.Flex.Worksheets;
namespace Unity.Flex;
public class FlexApplicationAutoMapperProfile : Profile
{
public FlexApplicationAutoMapperProfile()
{
CreateMap<Worksheet, WorksheetDto>()
.ForMember(dest => dest.TotalSections, opt => opt.MapFrom(s => s.Sections.Select(s => s.Id).Count()))
.ForMember(dest => dest.TotalFields, opt => opt.MapFrom(s => s.Sections.SelectMany(s => s.Fields).Count()));
CreateMap<WorksheetLink, WorksheetLinkDto>();
CreateMap<WorksheetSection, WorksheetSectionDto>();
CreateMap<WorksheetInstance, WorksheetInstanceDto>();
CreateMap<CustomFieldValue, CustomFieldValueDto>().ReverseMap();
CreateMap<CustomField, CustomFieldDto>();
CreateMap<Worksheet, WorksheetBasicDto>()
.ForMember(dest => dest.TotalSections, opt => opt.MapFrom(s => s.Sections.Select(s => s.Id).Count()))
.ForMember(dest => dest.TotalFields, opt => opt.MapFrom(s => s.Sections.SelectMany(s => s.Fields).Count()));
CreateMap<PersistWorksheetIntanceValuesDto, PersistWorksheetIntanceValuesEto>();
CreateMap<Question, QuestionDto>()
.ForMember(dest => dest.ExtraProperties, opt => opt.Ignore())
.ForMember(dest => dest.Answer, opt => opt.Ignore())
.ForMember(dest => dest.IsHumanConfirmed, opt => opt.Ignore())
.ForMember(dest => dest.AICitation, opt => opt.Ignore())
.ForMember(dest => dest.AIConfidence, opt => opt.Ignore());
CreateMap<ScoresheetSection, ScoresheetSectionDto>()
.ForMember(dest => dest.Fields, opt => opt.MapFrom(src => src.Fields))
.ForMember(dest => dest.ExtraProperties, opt => opt.Ignore());
CreateMap<Scoresheet, ScoresheetDto>()
.ForMember(dest => dest.Sections, opt => opt.MapFrom(src => src.Sections));
CreateMap<ScoresheetInstance, ScoresheetInstanceDto>();
CreateMap<Answer, AnswerDto>();
}
}