Files
Projet4/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs
carteronm 4e64112a31 First Commit 09/10
# Conflicts:
#	PyroFetes/PyroFetes.csproj
2025-10-16 17:34:55 +02:00

24 lines
742 B
C#

using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.ExperienceLevel.Response;
namespace PyroFetes.Endpoints.ExperienceLevel;
using FastEndpoints;
public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetExperienceLevelDto>>
{
public override void Configure()
{
Get ("/api/experienceLevels");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetExperienceLevelDto> experienceLevels= await pyroFetesDbContext.ExperienceLevels.Select(x => new GetExperienceLevelDto()
{
Id = x.Id,
}).ToListAsync(ct);
await Send.OkAsync(experienceLevels, ct);
}
}