1
0
mirror of synced 2024-11-28 08:00:49 +01:00
GC-local-server-rewrite/Application/Api/GetCardsQuery.cs
2023-02-17 00:38:01 +08:00

18 lines
688 B
C#

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);
}
}