using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Show.Response; namespace PyroFetes.Endpoints.Show; public class GetAllShowsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> { public override void Configure() { Get("/api/shows"); AllowAnonymous(); } public override async Task HandleAsync(CancellationToken ct) { var shows = await pyroFetesDbContext.Shows .Select(s => new ReadShowDto { Id = s.Id, Name = s.Name, Place = s.Place, Description = s.Description, PyrotechnicImplementationPlan = s.PyrotechnicImplementationPlan, Date = s.Date.HasValue ? s.Date.Value.ToDateTime(TimeOnly.MinValue) : null }) .ToListAsync(ct); await Send.OkAsync(shows, ct); } }