Files
PF3-fork/PyroFetes/Endpoints/Sound/GetAllSoundsEndpoint.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

35 lines
1011 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Sound.Response;
namespace PyroFetes.Endpoints.Sound;
public class GetAllSoundsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<ReadSoundDto>>
{
public override void Configure()
{
Get("/sounds");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
var sounds = await pyroFetesDbContext.Sounds
.Select(s => new ReadSoundDto
{
Id = s.Id,
Name = s.Name,
Type = s.Type,
Artist = s.Artist,
Duration = s.Duration != null ? s.Duration.Value.ToString() : null,
Kind = s.Kind,
Format = s.Format,
CreationDate = s.CreationDate,
SoundCategoryId = s.SoundCategoryId.ToString()
})
.ToListAsync(ct);
await Send.OkAsync(sounds, ct);
}
}