Finalisation endpoints
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using FastEndpoints;
|
||||
using PyroFetes.DTO.SoundTimecode.Request;
|
||||
using PyroFetes.DTO.SoundTimecode.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.SoundTimecode;
|
||||
|
||||
public class CreateSoundTimecodeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateSoundTimecodeDto, ReadSoundTimecodeDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/soundtimecodes");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateSoundTimecodeDto req, CancellationToken ct)
|
||||
{
|
||||
var soundTimecode = new PyroFetes.Models.SoundTimecode
|
||||
{
|
||||
ShowId = req.ShowId,
|
||||
SoundId = req.SoundId,
|
||||
Start = req.Start,
|
||||
End = req.End
|
||||
};
|
||||
|
||||
pyroFetesDbContext.SoundTimecodes.Add(soundTimecode);
|
||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||
|
||||
var result = new ReadSoundTimecodeDto
|
||||
{
|
||||
ShowId = soundTimecode.ShowId,
|
||||
SoundId = soundTimecode.SoundId,
|
||||
Start = (int)soundTimecode.Start,
|
||||
End = (int)soundTimecode.End
|
||||
};
|
||||
|
||||
await Send.OkAsync(result, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user