Finalisation endpoints

This commit is contained in:
2025-11-13 15:11:34 +01:00
parent 5c12a45ae6
commit 3a09bfc8ad
20 changed files with 922 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
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("/api/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);
}
}