semesterWork/Presence.Api/Controllers/GroupController.cs

37 lines
1.0 KiB
C#
Raw Normal View History

2024-12-04 21:58:43 +00:00
using domain.Service;
using domain.UseCase;
using Microsoft.AspNetCore.Mvc;
using Presence.Api.Response;
namespace Presence.Api.Controllers
{
[ApiController]
[Route("[controller]/api")]
public class GroupController: ControllerBase
{
private readonly IGroupUseCase _groupService;
public GroupController(IGroupUseCase groupService)
{
_groupService = groupService;
}
2024-12-07 15:33:26 +00:00
[HttpGet("/group")]
public async Task<ActionResult<GroupResponse>> GetAllGroups()
2024-12-04 21:58:43 +00:00
{
var result = _groupService
2024-12-07 15:33:26 +00:00
.GetGroupsWithStudents();
var response = result
2024-12-04 21:58:43 +00:00
.Select(group => new GroupResponse {
Id = group.Id,
Name = group.Name,
Users = group.Users.Select(user => new UserResponse {
Guid = user.Guid,
Name = user.Name
2024-12-07 15:33:26 +00:00
}).ToList(),
2024-12-04 21:58:43 +00:00
}).ToList();
return Ok(new GroupResponse());
}
}
}