Files
PyroFetes-Sujet1/PyroFetes/Endpoints/Effect/GetAllEffectsEndpoint.cs
2025-10-09 16:09:30 +02:00

27 lines
726 B
C#

using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Effect;
public class GetAllEffectsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetEffectDto>>
{
public override void Configure()
{
Get("/effects");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetEffectDto> responseDto = await pyrofetesdbcontext.Effects
.Select(a => new GetEffectDto
{
Id = a.Id,
Label = a.Label,
}
).ToListAsync(ct);
await Send.OkAsync(responseDto, ct);
}
}