using domain.UseCase; using Microsoft.AspNetCore.Mvc; using Presence.API.Response; using System; using System.Linq; namespace Presence.API.Controllers { [ApiController] [Route("api/[controller]")] public class PresenceController : ControllerBase { private readonly IPresenceUseCase _presenceUseCase; public PresenceController(IPresenceUseCase presenceUseCase) { _presenceUseCase = presenceUseCase; } [HttpGet("/presence/{groupId}")] public ActionResult GetPresence( int groupId, [FromQuery] int? subject, [FromQuery] DateTime? date, [FromQuery] int? student) { var presences = _presenceUseCase.GetPresence(groupId, subject, date, student) .Select(p => new PresenceResponse { Id = p.Id, StudentId = p.StudentId, StudentName = $"{p.Student.LastName} {p.Student.FirstName} {p.Student.Patronymic}", SubjectId = p.SubjectId, SubjectName = p.Subject.Name, Date = p.Date }) .ToList(); return Ok(presences); } } }