Files
AP-WEB-PF3/PF3/Endpoint/Show/GetShowEndpoint.cs
2025-10-09 17:54:25 +02:00

46 lines
1.5 KiB
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
.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);
}
}