Refactored User
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user