#27 get last receipt, get minimalUser, get my user

This commit is contained in:
Dominic Villemure
2024-05-12 16:40:24 -04:00
parent 3f20563850
commit 5161e3a91a
17 changed files with 216 additions and 24 deletions

View File

@@ -0,0 +1,29 @@
using Hutopy.Application.Common.Interfaces;
namespace Hutopy.Application.Stripe.Queries;
public record GetMyLastReceiptQuery : IRequest<MyLastReceiptDto>
{
public string Email { get; set; } = string.Empty;
public string CreatorId { get; set; } = string.Empty;
};
public class GetMyLastReceiptQueryHandler(
IApplicationDbContext dbContext
)
: IRequestHandler<GetMyLastReceiptQuery, MyLastReceiptDto>
{
public async Task<MyLastReceiptDto> Handle(GetMyLastReceiptQuery request, CancellationToken cancellationToken)
{
var lastTransaction = await dbContext.UserTransactions.OrderBy(x => x.Created)
.LastOrDefaultAsync(x => x.ApplicationUserId == request.CreatorId && x.StripeBillingDetailEmail == request.Email,
cancellationToken);
var receiptUrl = new MyLastReceiptDto
{
ReceiptUrl = lastTransaction?.StripeReceiptUrl ?? "",
};
return receiptUrl;
}
}