28 lines
898 B
C#
28 lines
898 B
C#
using BeReadyBackend.DTO.Groups;
|
|
using BeReadyBackend.Repositories;
|
|
using BeReadyBackend.Services;
|
|
using BeReadyBackend.Specifications.Groups;
|
|
using FastEndpoints;
|
|
|
|
namespace BeReadyBackend.Endpoints.Groups;
|
|
|
|
public class UserGroupRequest
|
|
{
|
|
public int Id { get; set; }
|
|
}
|
|
|
|
public class GetAllGroupUsersEndpoint(UserGroupsRepository userGroupsRepository, UserService userService) : Endpoint<UserGroupRequest, List<GetUserGroupDto>>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Get("/Groups/{@Id}/Users/", x => new { x.Id });
|
|
}
|
|
|
|
public override async Task HandleAsync(UserGroupRequest req, CancellationToken ct)
|
|
{
|
|
int userId = userService.GetUserIdFromToken();
|
|
|
|
List<GetUserGroupDto> usersGroup = await userGroupsRepository.ProjectToListAsync<GetUserGroupDto>(new GetUserGroupByIdSpec(req.Id, userId), ct);
|
|
await Send.OkAsync(usersGroup, ct);
|
|
}
|
|
} |