using API.DTO.Classification.Request; using API.DTO.Classification.Response; using FastEndpoints; namespace PyroFetes.Endpoints.Classification; public class CreateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint { public override void Configure() { Post("/api/classifications"); AllowAnonymous(); } public override async Task HandleAsync(CreateClassificationDto req, CancellationToken ct) { Models.Classification classification = new () { Label = req.Label }; pyrofetesdbcontext.Classifications.Add(classification); await pyrofetesdbcontext.SaveChangesAsync(ct); Console.WriteLine("Classification créée avec succès !"); GetClassificationDto responseDto = new () { Label = req.Label }; await Send.OkAsync(responseDto, ct); } }