Files
PF3-fork/PyroFetes/Endpoints/Show/DeleteShowEndpoint.cs
T
cernont 6c1330e570 Fix FastEndpoints/Swagger wiring and missing required fields in DTOs
- Register FastEndpoints, SwaggerDocument, DbContext in Program.cs
- Add DbContextOptions constructor to PyroFetesDbContext
- Add CityId to Show DTOs and endpoints (NOT NULL in DB)
- Add F4T2NumberApproval/F4T2ExpirationDate to Staff DTOs and endpoints
- Simplify DeleteShow to rely on DB cascade instead of manual includes
- Default NOT NULL string fields to empty string on create

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 19:35:01 +02:00

38 lines
903 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Show.Request;
namespace PyroFetes.Endpoints.Show;
public class DeleteShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<IdShowDto>
{
public override void Configure()
{
Delete("/api/shows/{Id}");
AllowAnonymous();
}
public override async Task HandleAsync(IdShowDto req, CancellationToken ct)
{
if (!req.Id.HasValue)
{
await Send.NotFoundAsync(ct);
return;
}
var show = await pyroFetesDbContext.Shows
.FirstOrDefaultAsync(s => s.Id == req.Id.Value, ct);
if (show is null)
{
await Send.NotFoundAsync(ct);
return;
}
pyroFetesDbContext.Shows.Remove(show);
await pyroFetesDbContext.SaveChangesAsync(ct);
await Send.OkAsync(ct);
}
}