+ Tips
+ Memberships - DDD - FutureCreator - UserTransactions
This commit is contained in:
45
src/Web/Features/Memberships/Handlers/GetSentTips.cs
Normal file
45
src/Web/Features/Memberships/Handlers/GetSentTips.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Features.Memberships.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Memberships.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record struct TipSentModel(
|
||||
Guid Id,
|
||||
DateTimeOffset CreatedAt,
|
||||
Guid CreatorId,
|
||||
string CreatorName,
|
||||
decimal Amount,
|
||||
string Currency,
|
||||
string Message);
|
||||
|
||||
[PublicAPI]
|
||||
public class GetSentTipsHandler(
|
||||
MembershipDbContext dbContext)
|
||||
: EndpointWithoutRequest<List<TipSentModel>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/tips/sent");
|
||||
Options(o => o.WithTags("Memberships"));
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
CancellationToken ct)
|
||||
{
|
||||
var tips = await dbContext
|
||||
.Tips
|
||||
.Where(t => t.TipperId == User.GetUserId())
|
||||
.Select(tip => new TipSentModel(
|
||||
tip.Id,
|
||||
tip.CreatedAt,
|
||||
tip.CreatorId,
|
||||
tip.CreatorName,
|
||||
tip.Amount,
|
||||
tip.Currency,
|
||||
tip.Message))
|
||||
.ToListAsync(ct);
|
||||
|
||||
await SendOkAsync(tips, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user