using FastEndpoints; using Microsoft.EntityFrameworkCore; using PF3.DTO.Show.Response; using PF3.Migrations; namespace PF3.Endpoint.Show; public class GetShowEndpoint(PyroFetesDbContext pyroFetesDbContext):Endpoint { public override void Configure() { Get("/api/shows/{Id}", a=> a.Id!); AllowAnonymous(); } public override async Task HandleAsync(ReadShowDto req, CancellationToken ct) { var show = await pyroFetesDbContext.Shows .Include(s => s.City) .Include(s => s.ShowStaffs) .Include(s => s.ShowTrucks) .Include(s => s.SoundTimecodes) .Include(s => s.ProductTimecodes) .Include(s => s.Contracts) .Include(s => s.ShowMaterials) .Where(a => a.Id == req.Id) .Select(a => new ReadShowDto { Id = req.Id, Name = req.Name, Place = req.Place, Description = req.Description, PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan, CityId = a.CityId, City = a.City!.Name, ShowStaffs = a.ShowStaffs, ShowTrucks = a.ShowTrucks, SoundTimecodes = a.SoundTimecodes, ProductTimecodes = a.ProductTimecodes, Contracts = a.Contracts, ShowMaterials = a.ShowMaterials, }) .FirstOrDefaultAsync(ct); await Send.OkAsync(show, ct); } }