Files
PF3-fork/PyroFetes/Endpoints/Show/GetAllShowsEndpoint.cs
2025-11-13 15:11:34 +01:00

32 lines
930 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Show.Response;
namespace PyroFetes.Endpoints.Show;
public class GetAllShowsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<ReadShowDto>>
{
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);
}
}