Files
PyroFetes-Sujet1/PyroFetes/Endpoints/Login/GetAllLoginEndpoint.cs
2025-12-08 12:27:05 +01:00

29 lines
782 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Login.Response;
namespace PyroFetes.Endpoints.Login;
public class GetAllLoginEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetLoginDto>>
{
public override void Configure()
{
Get("/logins");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetLoginDto> logins = await database.Users
.Select(login => new GetLoginDto()
{
Id = login.Id,
Name = login.Name,
Password = login.Password,
Fonction = login.Fonction
})
.ToListAsync(ct);
await Send.OkAsync(logins, ct);
}
}