feat(directory): flesh out GetSoftware query

This commit is contained in:
Collin M. Barrett 2020-08-28 15:13:27 -05:00
parent 0885d53a87
commit 571cc8b7fb

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<SoftwareViewModel>> Handle(
CancellationToken cancellationToken)
{
return await _context.Software
.OrderBy(s => s.Id)
.ProjectTo<SoftwareViewModel>(_mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);
}
@ -42,7 +44,10 @@ public class SoftwareViewModelProfile : Profile
{
public SoftwareViewModelProfile()
{
CreateMap<Software, SoftwareViewModel>();
CreateMap<Software, SoftwareViewModel>()
.ForMember(s => s.SyntaxIds,
o => o.MapFrom(s =>
s.SoftwareSyntaxes.Select(ss => ss.SyntaxId).OrderBy(sid => sid)));
}
}