Files
Knots/Knots/Endpoints/User/GetAllUsersEndpoint.cs
2026-03-12 17:11:48 +01:00

24 lines
611 B
C#

using FastEndpoints;
using Knots.DTO.User;
using Microsoft.EntityFrameworkCore;
namespace Knots.Endpoints.User;
public class GetAllUsersEndpoint(KnotsDbContext knotsDbContext) : EndpointWithoutRequest<List<GetUserDto>>
{
public override void Configure()
{
Get ("/users");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetUserDto> users= await knotsDbContext.Users.Select(x => new GetUserDto()
{
Username = x.Username,
}).ToListAsync(ct);
await Send.OkAsync(users, ct);
}
}