presence/Presence.API/Controllers/AdminController.cs
2024-12-05 10:31:49 +03:00

38 lines
1.1 KiB
C#

using domain.UseCase;
using domain.Request;
using Microsoft.AspNetCore.Mvc;
namespace Presence.API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class AdminController : ControllerBase
{
private readonly IAdminUseCase _adminUseCase;
public AdminController(IAdminUseCase adminUseCase)
{
_adminUseCase = adminUseCase;
}
[HttpPost("/group/{groupId}/students")]
public IActionResult AddStudentsToGroup(int groupId, [FromBody] AddStudentsToGroupRequest request)
{
if (request?.Students == null)
return BadRequest();
_adminUseCase.AddStudentsToGroup(groupId, request);
return NoContent();
}
[HttpPost("/group/{groupId}/subjects")]
public IActionResult AddSubjectsToGroup(int groupId, [FromBody] AddSubjectsToGroupRequest request)
{
if (request?.Subjects == null)
return BadRequest();
_adminUseCase.AddSubjectsToGroup(groupId, request);
return NoContent();
}
}
}