b3612f5bec
- Strip /api prefix from all endpoint routes - Make Show.CityId nullable (no longer required FK) - Drop CityId FK constraint and alter column to NULL at startup via raw SQL - Add migration MakeCityIdNullable for schema consistency - Update Show DTOs to reflect nullable CityId Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
754 B
C#
29 lines
754 B
C#
using FastEndpoints;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using PyroFetes.DTO.Staff.Request;
|
|
|
|
namespace PyroFetes.Endpoints.Staff;
|
|
|
|
public class DeleteStaffEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdStaffDto>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Delete("/staff/{Id}");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(IdStaffDto req, CancellationToken ct)
|
|
{
|
|
var staff = await pf3DbContext.Staffs.FirstOrDefaultAsync(s => s.Id == req.Id, ct);
|
|
if (staff is null)
|
|
{
|
|
await Send.NotFoundAsync(ct);
|
|
return;
|
|
}
|
|
|
|
pf3DbContext.Staffs.Remove(staff);
|
|
await pf3DbContext.SaveChangesAsync(ct);
|
|
|
|
await Send.OkAsync(ct);
|
|
}
|
|
} |