Files
PF3-fork/PyroFetes/Endpoints/SoundTimecode/GetSoundTimecodeEndpoint.cs
T
cernont b3612f5bec Remove /api prefix from all routes and fix CityId FK constraint
- Strip /api prefix from all endpoint routes
- Make Show.CityId nullable (no longer required FK)
- Drop CityId FK constraint and alter column to NULL at startup via raw SQL
- Add migration MakeCityIdNullable for schema consistency
- Update Show DTOs to reflect nullable CityId

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 20:32:55 +02:00

44 lines
1.2 KiB
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SoundTimecode.Response;
namespace PyroFetes.Endpoints.SoundTimecode;
// DTO pour la route avec clé composite
public class GetSoundTimecodeRequest
{
public int ShowId { get; set; }
public int SoundId { get; set; }
}
public class GetSoundTimecodeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<GetSoundTimecodeRequest, ReadSoundTimecodeDto>
{
public override void Configure()
{
Get("/soundtimecodes/{ShowId}/{SoundId}");
AllowAnonymous();
}
public override async Task HandleAsync(GetSoundTimecodeRequest req, CancellationToken ct)
{
var soundTimecode = await pyroFetesDbContext.SoundTimecodes
.Where(st => st.ShowId == req.ShowId && st.SoundId == req.SoundId)
.Select(st => new ReadSoundTimecodeDto
{
ShowId = st.ShowId,
SoundId = st.SoundId,
Start = (int)st.Start,
End = (int)st.End
})
.FirstOrDefaultAsync(ct);
if (soundTimecode is null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(soundTimecode, ct);
}
}