using API.DTO.Brand.Request; using API.DTO.Brand.Response; using FastEndpoints; namespace PyroFetes.Endpoints.Brand; public class CreateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint { public override void Configure() { Post("/api/brands"); AllowAnonymous(); } public override async Task HandleAsync(CreateBrandDto req, CancellationToken ct) { Models.Brand brand = new () { Name = req.Name }; pyrofetesdbcontext.Brands.Add(brand); await pyrofetesdbcontext.SaveChangesAsync(ct); Console.WriteLine("Marque créé avec succès !"); GetBrandDto responseDto = new () { Name = req.Name }; await Send.OkAsync(responseDto, ct); } }