Files
PF3-fork/PyroFetes/Endpoints/Show/CreateShowEndpoint.cs
T
cernont 71b7a53e59 Migrate Show.Date from DateOnly to DateTime to support time of day
Removes DateOnly/DateTime conversion boilerplate from all Show endpoints
and adds the corresponding EF Core migration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 18:01:12 +02:00

44 lines
1.2 KiB
C#

using FastEndpoints;
using PyroFetes.DTO.Show.Request;
using PyroFetes.DTO.Show.Response;
namespace PyroFetes.Endpoints.Show;
public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateShowDto, ReadShowDto>
{
public override void Configure()
{
Post("/shows");
AllowAnonymous();
}
public override async Task HandleAsync(CreateShowDto req, CancellationToken ct)
{
var show = new PyroFetes.Models.Show
{
Name = req.Name ?? string.Empty,
Place = req.Place ?? string.Empty,
Description = req.Description,
PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan ?? string.Empty,
Date = req.Date,
CityId = req.CityId
};
pyroFetesDbContext.Shows.Add(show);
await pyroFetesDbContext.SaveChangesAsync(ct);
var result = new ReadShowDto
{
Id = show.Id,
Name = show.Name,
Place = show.Place,
Description = show.Description,
PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan,
Date = show.Date,
CityId = show.CityId
};
await Send.OkAsync(result, ct);
}
}