Files
AP-WEB-PF3/PF3/Endpoint/Show/GetShowEndpoint.cs

31 lines
908 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PF3.DTO.Show.Response;
using PF3.Migrations;
namespace PF3.Endpoint.Show;
public class GetShowEndpoint(PyroFetesDbContext pyroFetesDbContext):Endpoint<ReadShowDto>
{
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
.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
})
.FirstOrDefaultAsync(ct);
await Send.OkAsync(show, ct);
}
}