forked from sanchezvem/PyroFetes
29 lines
782 B
C#
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);
|
|
}
|
|
} |