24 lines
611 B
C#
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);
|
|
}
|
|
} |