création CreateShowEndpoint.cs et rectification quelque chemin

This commit is contained in:
2025-10-09 15:55:00 +02:00
parent c6ce3c658f
commit 139e849e41
62 changed files with 193 additions and 69 deletions

View File

@@ -1,10 +1,12 @@
using FastEndpoints;
using PF3.DTO.Show.Request;
using PF3.DTO.Show.Response;
using PF3.Migrations;
using PyroFetes;
namespace PF3.Endpoint.Show;
public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext):Endpoint<CreateShowEndpoint, ReadShowDto>
public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext):Endpoint<CreateShowDto, ReadShowDto>
{
public override void Configure()
{
@@ -12,8 +14,29 @@ public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext):Endpoint<
AllowAnonymous();
}
public override Task HandleAsync(CreateShowEndpoint req, CancellationToken ct)
public override async Task HandleAsync(CreateShowDto req, CancellationToken ct)
{
var show = new Models.Show
{
Name = req.Name,
Place = req.Place,
Description = req.Description,
Date = req.Date,
PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan
};
pyroFetesDbContext.Shows.Add(show);
await pyroFetesDbContext.SaveChangesAsync(ct);
ReadShowDto readShowDto = new ReadShowDto()
{
Id = show.Id,
Name = show.Name,
Place = show.Place,
Description = show.Description,
PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan
};
await Send.OkAsync(readShowDto, ct);
}
}