CreateShowEndpoint.cs et GetShowEndpoint.cs fini

This commit is contained in:
2025-10-09 16:52:04 +02:00
parent 139e849e41
commit 9d5b3474c2
2 changed files with 32 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext):Endpoint<
{
public override void Configure()
{
Post("/api/show");
Post("/api/shows");
AllowAnonymous();
}

View File

@@ -0,0 +1,31 @@
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);
}
}