Files
BeReadyBackend/BeReadyBackend/Endpoints/Groups/GetAllGroupsEndpoint.cs
T
2026-02-22 16:02:34 +01:00

23 lines
749 B
C#

using BeReadyBackend.DTO.Groups;
using BeReadyBackend.Repositories;
using BeReadyBackend.Services;
using BeReadyBackend.Specifications.Groups;
using FastEndpoints;
namespace BeReadyBackend.Endpoints.Groups;
public class GetAllGroupsEndpoint(UserGroupsRepository userGroupsRepository, UserService userService) : EndpointWithoutRequest<List<GetGroupDto>>
{
public override void Configure()
{
Get("/Groups/Users/");
}
public override async Task HandleAsync(CancellationToken ct)
{
int userId = userService.GetUserIdFromToken();
List<GetGroupDto> groups = await userGroupsRepository.ProjectToListAsync<GetGroupDto>(new GetGroupsByUserIdSpec(userId), ct);
await Send.OkAsync(groups, ct);
}
}