using Microsoft.AspNetCore.Mvc; using UniversityContracts.BindingModels; using UniversityContracts.BusinessLogicContracts; using UniversityContracts.SearchModels; using UniversityContracts.ViewModels; namespace UniversityRestAPI.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class EducationStatusController : Controller { private readonly IEducationStatusLogic _educationStatusLogic; public EducationStatusController(IEducationStatusLogic educationStatusLogic) { _educationStatusLogic = educationStatusLogic; } [HttpGet] public EducationStatusViewModel? Get(int id) { try { return _educationStatusLogic.ReadElement(new EducationStatusSearchModel { Id = id }); } catch (Exception ex) { throw; } } [HttpGet] public List? GetAllByUser(int userId) { try { return _educationStatusLogic.ReadList(new EducationStatusSearchModel { UserId = userId }); } catch (Exception ex) { throw; } } [HttpGet] public List? GetMany(int userId, int page) { try { return _educationStatusLogic.ReadList(new EducationStatusSearchModel { UserId = userId, PageNumber = page, PageSize = 10 }); } catch (Exception ex) { throw; } } [HttpGet] public int GetNumberOfPages(int userId) { try { return _educationStatusLogic.GetNumberOfPages(userId); } catch (Exception ex) { throw; } } [HttpGet] public List GetEducationStatusStudents() { try { return _educationStatusLogic.GetEducationStatusStudents(); } catch (Exception ex) { throw; } } [HttpPost] public void Create(EducationStatusBindingModel model) { try { _educationStatusLogic.Create(model); } catch (Exception ex) { throw; } } [HttpPost] public void Update(EducationStatusBindingModel model) { try { _educationStatusLogic.Update(model); } catch (Exception ex) { throw; } } [HttpPost] public void Delete(EducationStatusBindingModel model) { try { _educationStatusLogic.Delete(new() { Id = model.Id }); } catch (Exception ex) { throw; } } } }