Finalisation endpoints
This commit is contained in:
31
PyroFetes/Endpoints/Show/GetAllShowsEndpoint.cs
Normal file
31
PyroFetes/Endpoints/Show/GetAllShowsEndpoint.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user