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