add Languages to List summary API endpoint

This commit is contained in:
Collin M. Barrett 2018-02-20 20:04:19 -06:00
parent 15a39e31d2
commit f05ad24d33
2 changed files with 13 additions and 3 deletions

View file

@ -1,8 +1,11 @@
namespace FilterLists.Services.FilterListService
using System.Collections.Generic;
namespace FilterLists.Services.FilterListService
{
public class FilterListSummaryDto
{
public int Id { get; set; }
public IEnumerable<string> Languages { get; set; }
public string Name { get; set; }
public string ViewUrl { get; set; }
}

View file

@ -9,8 +9,15 @@ public class MappingProfiles : Profile
public MappingProfiles()
{
CreateMap<FilterList, FilterListDetailsDto>()
.ForMember(d => d.Languages,
opt => opt.MapFrom(c => c.FilterListLanguages.Select(x => x.Language.Name)));
.ForMember(dto => dto.Languages,
conf => conf.MapFrom(list =>
list.FilterListLanguages.Select(listLangs => listLangs.Language.Name)));
//TODO: improve performance (https://stackoverflow.com/q/48897083/2343739)
CreateMap<FilterList, FilterListSummaryDto>()
.ForMember(dto => dto.Languages,
conf => conf.MapFrom(list =>
list.FilterListLanguages.Select(listLangs => listLangs.Language.Name)));
}
}
}