using FastEndpoints; using PF3.DTO.Show.Request; using PF3.DTO.Show.Response; using PF3.Migrations; using PyroFetes; namespace PF3.Endpoint.Show; public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext):Endpoint { public override void Configure() { Post("/api/shows"); AllowAnonymous(); } public override async Task HandleAsync(CreateShowDto req, CancellationToken ct) { var show = new Models.Show { Name = req.Name, Place = req.Place, Description = req.Description, Date = req.Date, PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan }; pyroFetesDbContext.Shows.Add(show); await pyroFetesDbContext.SaveChangesAsync(ct); ReadShowDto readShowDto = new ReadShowDto() { Id = show.Id, Name = show.Name, Place = show.Place, Description = show.Description, PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan }; await Send.OkAsync(readShowDto, ct); } }