feat(directory): flesh out GetLicenses query

This commit is contained in:
Collin M. Barrett 2020-08-28 15:05:23 -05:00
parent d00e911794
commit b794fa559c

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
@ -33,6 +34,7 @@ public async Task<IEnumerable<LicenseViewModel>> Handle(
CancellationToken cancellationToken)
{
return await _context.Licenses
.OrderBy(l => l.Id)
.ProjectTo<LicenseViewModel>(_mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);
}
@ -42,7 +44,10 @@ public class LicenseViewModelProfile : Profile
{
public LicenseViewModelProfile()
{
CreateMap<License, LicenseViewModel>();
CreateMap<License, LicenseViewModel>()
.ForMember(l => l.FilterListIds,
o => o.MapFrom(l =>
l.FilterLists.Select(fl => fl.Id).OrderBy(flid => flid)));
}
}
@ -50,8 +55,10 @@ public class LicenseViewModel
{
public int Id { get; private set; }
public string Name { get; private set; } = null!;
public string? GitHubKey { get; private set; }
public Uri? Url { get; private set; }
public bool PermitsModification { get; private set; }
public bool PermitsDistribution { get; private set; }
public bool PermitsCommercialUse { get; private set; }
public IEnumerable<int>? FilterListIds { get; private set; }
}
}