32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using FastEndpoints;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Socialize.Api.Data;
|
|
using Socialize.Api.Infrastructure.Security;
|
|
using Socialize.Api.Modules.Feedback.Contracts;
|
|
|
|
namespace Socialize.Api.Modules.Feedback.Handlers;
|
|
|
|
public class ListMyFeedbackHandler(AppDbContext dbContext)
|
|
: EndpointWithoutRequest<IReadOnlyCollection<FeedbackReportDto>>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Get("/api/my-feedback");
|
|
Options(o => o.WithTags("Feedback"));
|
|
}
|
|
|
|
public override async Task HandleAsync(CancellationToken ct)
|
|
{
|
|
Guid reporterUserId = User.GetUserId();
|
|
List<FeedbackReportDto> reports = await dbContext.FeedbackReports
|
|
.Include(report => report.Tags)
|
|
.Include(report => report.Screenshot)
|
|
.Where(report => report.ReporterUserId == reporterUserId)
|
|
.OrderByDescending(report => report.LastActivityAt)
|
|
.Select(report => report.ToDto())
|
|
.ToListAsync(ct);
|
|
|
|
await SendOkAsync(reports, ct);
|
|
}
|
|
}
|