37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
|
using domain.Service;
|
|||
|
using domain.UseCase;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Presence.Api.Response;
|
|||
|
|
|||
|
namespace Presence.Api.Controllers
|
|||
|
{
|
|||
|
[ApiController]
|
|||
|
[Route("api/[contrtoller]")]
|
|||
|
public class GroupController: ControllerBase
|
|||
|
{
|
|||
|
private readonly IGroupUseCase _groupService;
|
|||
|
|
|||
|
public GroupController(IGroupUseCase groupService) {
|
|||
|
_groupService = groupService;
|
|||
|
}
|
|||
|
|
|||
|
[HttpGet("/group")]
|
|||
|
public ActionResult<GroupResponse> GetAllGroups() {
|
|||
|
|
|||
|
var result = _groupService
|
|||
|
.GetGroupsWithStudents()
|
|||
|
.Select(group => new GroupResponse {
|
|||
|
Id = group.Id,
|
|||
|
Name = group.Name,
|
|||
|
Users = group.Users?.Select(
|
|||
|
user => new UserResponse {
|
|||
|
Guid = user.Guid,
|
|||
|
Name = user.Name,
|
|||
|
}).Take(10).ToList()
|
|||
|
}).ToList();
|
|||
|
return Ok(result);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|