using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Staff.Request; using PyroFetes.DTO.Staff.Response; using FastEndpoints; namespace PyroFetes.Endpoints.Staff; public class DeleteStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { Delete ("/api/staff/{@Id}", x => new { x.Id }); AllowAnonymous(); } public override async Task HandleAsync(GetStaffRequest req, CancellationToken ct) { Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); if (databaseStaff == null) { await Send.NotFoundAsync(ct); return; } pyroFetesDbContext.Staffs.Remove(databaseStaff); await pyroFetesDbContext.SaveChangesAsync(ct); await Send.NoContentAsync(ct); } }