Files
git/GetAllEffectsEndpoint.cs

27 lines
702 B
C#

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