Files
PyroFetes/PyroFetes/Endpoints/User/GetAllUsersEndpoint.cs
2025-10-27 12:31:25 +01:00

30 lines
813 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Response;
namespace PyroFetes.Endpoints.User;
public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetUserDto>>
{
public override void Configure()
{
Get("/api/users");
}
public override async Task HandleAsync(CancellationToken ct)
{
var users = await database.Users
.Select(users => new GetUserDto()
{
Id = users.Id,
Name = users.Name,
Password = users.Password,
Salt = users.Salt,
Email = users.Email,
Fonction = users.Fonction
})
.ToListAsync(ct);
await Send.OkAsync(users, ct);
}
}