1
0
mirror of synced 2024-12-23 19:44:51 +01:00
GC-local-server-rewrite/Application/Api/GetCardsQuery.cs

18 lines
688 B
C#
Raw Normal View History

2023-02-16 17:38:01 +01:00
namespace Application.Api;
public record GetCardsQuery() : IRequestWrapper<List<ClientCardDto>>;
public class GetCardsQueryHandler : RequestHandlerBase<GetCardsQuery, List<ClientCardDto>>
{
public GetCardsQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate)
{
}
public override async Task<ServiceResult<List<ClientCardDto>>> Handle(GetCardsQuery request, CancellationToken cancellationToken)
{
var cards = await CardDbContext.CardMains.ToListAsync(cancellationToken: cancellationToken);
var dtoList = cards.Select(card => card.CardMainToClientDto()).ToList();
return new ServiceResult<List<ClientCardDto>>(dtoList);
}
}