mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(directory): ✨ flesh out GetLicenses query
This commit is contained in:
parent
d00e911794
commit
b794fa559c
1 changed files with 9 additions and 2 deletions
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue