From 9d5b3474c2da715dedaf89a7ef3db7f09aba95c7 Mon Sep 17 00:00:00 2001 From: cernont Date: Thu, 9 Oct 2025 16:52:04 +0200 Subject: [PATCH] CreateShowEndpoint.cs et GetShowEndpoint.cs fini --- PF3/Endpoint/Show/CreateShowEndpoint.cs | 2 +- PF3/Endpoint/Show/GetShowEndpoint.cs | 31 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 PF3/Endpoint/Show/GetShowEndpoint.cs diff --git a/PF3/Endpoint/Show/CreateShowEndpoint.cs b/PF3/Endpoint/Show/CreateShowEndpoint.cs index a89df07..6d7c9fe 100644 --- a/PF3/Endpoint/Show/CreateShowEndpoint.cs +++ b/PF3/Endpoint/Show/CreateShowEndpoint.cs @@ -10,7 +10,7 @@ public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext):Endpoint< { public override void Configure() { - Post("/api/show"); + Post("/api/shows"); AllowAnonymous(); } diff --git a/PF3/Endpoint/Show/GetShowEndpoint.cs b/PF3/Endpoint/Show/GetShowEndpoint.cs new file mode 100644 index 0000000..070e4fa --- /dev/null +++ b/PF3/Endpoint/Show/GetShowEndpoint.cs @@ -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 +{ + 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); + } +} \ No newline at end of file