refactor mapping profiles

ref #330
This commit is contained in:
Collin Barrett 2018-08-11 14:29:50 -05:00
parent 24c4ec2f4d
commit 33b0b2ecb4

View file

@ -9,10 +9,19 @@ public class MappingProfiles : Profile
{
public MappingProfiles()
{
CreateListSummaryDtoMap();
CreateListDetailsDtoMap();
CreateListMaintainerDtoMap();
CreateListSyntaxDtoMap();
}
private void CreateListSummaryDtoMap() =>
CreateMap<Data.Entities.FilterList, ListSummaryDto>()
.ForMember(dto => dto.Languages,
conf => conf.MapFrom(list => list.FilterListLanguages.Select(listLangs => listLangs.Language)))
.ForMember(dto => dto.AddedDate, conf => conf.MapFrom(list => list.CreatedDateUtc));
private void CreateListDetailsDtoMap() =>
CreateMap<Data.Entities.FilterList, ListDetailsDto>()
.ForMember(dto => dto.Languages,
conf => conf.MapFrom(list => list.FilterListLanguages.Select(listLangs => listLangs.Language.Name)))
@ -20,13 +29,16 @@ public MappingProfiles()
conf => conf.MapFrom(list =>
list.FilterListMaintainers.Select(listMaints => listMaints.Maintainer)))
.ForMember(dto => dto.AddedDate, conf => conf.MapFrom(list => list.CreatedDateUtc));
private void CreateListMaintainerDtoMap() =>
CreateMap<Maintainer, ListMaintainerDto>()
.ForMember(dto => dto.AdditionalLists,
conf => conf.MapFrom(maint =>
maint.FilterListMaintainers.Select(listMaints => listMaints.FilterList)));
private void CreateListSyntaxDtoMap() =>
CreateMap<Syntax, ListSyntaxDto>()
.ForMember(dto => dto.SupportedSoftware,
conf => conf.MapFrom(syntax => syntax.SoftwareSyntaxes.Select(softSyn => softSyn.Software)));
}
}
}