Files
PF3-fork/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs
T
cernont b3612f5bec Remove /api prefix from all routes and fix CityId FK constraint
- 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>
2026-05-27 20:32:55 +02:00

44 lines
1.2 KiB
C#

using FastEndpoints;
using PyroFetes.DTO.Staff.Request;
using PyroFetes.DTO.Staff.Response;
namespace PyroFetes.Endpoints.Staff;
public class CreateStaffEndpoint(PyroFetesDbContext pf3DbContext):Endpoint<CreateStaffDto, ReadStaffDto>
{
public override void Configure()
{
Post("/staff");
AllowAnonymous();
}
public override async Task HandleAsync(CreateStaffDto req, CancellationToken ct)
{
var staff = new PyroFetes.Models.Staff
{
FirstName = req.FirstName,
LastName = req.LastName,
Profession = req.Profession,
Email = req.Email,
F4T2NumberApproval = req.F4T2NumberApproval,
F4T2ExpirationDate = req.F4T2ExpirationDate
};
pf3DbContext.Staffs.Add(staff);
await pf3DbContext.SaveChangesAsync(ct);
var result = new ReadStaffDto()
{
Id = staff.Id,
FirstName = staff.FirstName,
LastName = staff.LastName,
Profession = staff.Profession,
Email = staff.Email,
F4T2NumberApproval = staff.F4T2NumberApproval,
F4T2ExpirationDate = staff.F4T2ExpirationDate
};
await Send.OkAsync(result, ct);
}
}