2023-05-17 16:47:38 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2023-05-17 22:54:39 +04:00
|
|
|
|
using UniversityContracts.BindingModels;
|
|
|
|
|
using UniversityContracts.BusinessLogicContracts;
|
|
|
|
|
using UniversityContracts.SearchModels;
|
|
|
|
|
using UniversityContracts.ViewModels;
|
2023-05-17 16:47:38 +04:00
|
|
|
|
|
|
|
|
|
namespace UniversityRestAPI.Controllers
|
|
|
|
|
{
|
2023-05-17 22:54:39 +04:00
|
|
|
|
[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<EducationStatusViewModel>? GetAllByUser(int userId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-18 04:35:12 +04:00
|
|
|
|
return _educationStatusLogic.ReadList(new EducationStatusSearchModel { UserId = userId });
|
2023-05-17 22:54:39 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<EducationStatusViewModel>? 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 14:46:02 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<EducationStatusStudentsCountViewModel> GetEducationStatusStudents()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _educationStatusLogic.GetEducationStatusStudents();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 22:54:39 +04:00
|
|
|
|
[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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-17 16:47:38 +04:00
|
|
|
|
}
|