37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using BackOffice.BFF.Commission.Protobuf;
|
|
|
|
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
|
|
|
|
public class GetWithdrawalRequestsQueryHandler : IRequestHandler<GetWithdrawalRequestsQuery, GetWithdrawalRequestsResponseDto>
|
|
{
|
|
private readonly IApplicationContractContext _context;
|
|
|
|
public GetWithdrawalRequestsQueryHandler(IApplicationContractContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<GetWithdrawalRequestsResponseDto> Handle(GetWithdrawalRequestsQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var grpcRequest = new GetWithdrawalRequestsRequest
|
|
{
|
|
PageIndex = request.PageIndex,
|
|
PageSize = request.PageSize
|
|
};
|
|
|
|
if (request.Status.HasValue)
|
|
{
|
|
grpcRequest.Status = request.Status.Value;
|
|
}
|
|
|
|
if (request.UserId.HasValue)
|
|
{
|
|
grpcRequest.UserId = request.UserId.Value;
|
|
}
|
|
|
|
var response = await _context.Commissions.GetWithdrawalRequestsAsync(grpcRequest, cancellationToken: cancellationToken);
|
|
|
|
return response.Adapt<GetWithdrawalRequestsResponseDto>();
|
|
}
|
|
}
|