création CreateShowEndpoint.cs et rectification quelque chemin
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user