using Microsoft.AspNetCore.Mvc; using Demo.Data.RemoteData.RemoteDataBase.DAO; using Demo.Domain.UseCase; using Demo.Domain.Models; using System; using System.Collections.Generic; using System.Linq; namespace Demo.API.Controllers { [ApiController] [Route("api/[controller]")] public class PresenceController : ControllerBase { private readonly UseCasePresence _presenceUseCase; public PresenceController(UseCasePresence presenceUseCase) { _presenceUseCase = presenceUseCase; } [HttpGet("getPresenceByGroup")] public IActionResult GetPresenceByGroup([FromQuery] int groupId) { var presence = _presenceUseCase.GetPresenceByGroup(groupId); return Ok(presence); } [HttpPost("addPresence")] public IActionResult AddPresence([FromBody] Demo.Data.RemoteData.RemoteDataBase.DAO.Presence daoPresence) { var domainPresence = new Demo.Domain.Models.Presence { Id = daoPresence.Id, Date = daoPresence.Date, LessonNumber = daoPresence.LessonNumber, IsAttendance = daoPresence.IsAttendance, UserId = daoPresence.UserId }; _presenceUseCase.PresenceRepository.AddPresence(domainPresence); return Ok(); } [HttpPut("markUserAsAbsent")] public IActionResult MarkUserAsAbsent([FromQuery] Guid userId, [FromQuery] int lessonNumber, [FromQuery] DateTime date) { _presenceUseCase.MarkUserAsAbsent(userId, lessonNumber, date); return Ok(); } [HttpDelete("deletePresence")] public IActionResult DeletePresence([FromQuery] Guid id) { _presenceUseCase.PresenceRepository.DeletePresence(id); return Ok(); } } }