feat(directory): flesh out GetLanguages query

This commit is contained in:
Collin M. Barrett 2020-08-28 13:27:22 -05:00
parent 734b7d4e5f
commit d00e911794

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
@ -32,6 +33,8 @@ public async Task<IEnumerable<LanguageViewModel>> Handle(
CancellationToken cancellationToken)
{
return await _context.Languages
.Where(l => l.FilterListLanguages.Any())
.OrderBy(l => l.Iso6391)
.ProjectTo<LanguageViewModel>(_mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);
}
@ -41,7 +44,10 @@ public class LicenseViewModelProfile : Profile
{
public LicenseViewModelProfile()
{
CreateMap<Language, LanguageViewModel>();
CreateMap<Language, LanguageViewModel>()
.ForMember(l => l.FilterListIds,
o => o.MapFrom(l =>
l.FilterListLanguages.Select(fll => fll.FilterListId).OrderBy(flid => flid)));
}
}