Refactored User

This commit is contained in:
Cristiano
2025-11-20 15:38:53 +01:00
parent 0b72549143
commit 165c9b9322
11 changed files with 76 additions and 77 deletions

View File

@@ -1,10 +1,11 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Response;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Users;
public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetUserDto>>
public class GetAllUsersEndpoint(UsersRepository usersRepository) : EndpointWithoutRequest<List<GetUserDto>>
{
public override void Configure()
{
@@ -14,18 +15,6 @@ public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutR
public override async Task HandleAsync(CancellationToken ct)
{
List<GetUserDto> 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);
await Send.OkAsync(await usersRepository.ProjectToListAsync<GetUserDto>(ct), ct);
}
}