2024-04-29 19:06:11 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using UniversityContracts.BindingModels;
|
|
|
|
|
using UniversityContracts.BusinessLogicsContracts;
|
|
|
|
|
using UniversityContracts.SearchModels;
|
|
|
|
|
using UniversityContracts.ViewModels;
|
|
|
|
|
|
|
|
|
|
namespace UniversityRestApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class PlanOfStudysController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IPlanOfStudyLogic _logic;
|
|
|
|
|
public PlanOfStudysController(IPlanOfStudyLogic logic, ILogger<PlanOfStudysController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logic = logic;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<PlanOfStudyViewModel>? GetPlanOfStudys(int userId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-05-27 01:11:57 +04:00
|
|
|
|
return _logic.ReadList(new PlanOfStudySearchModel { UserId = userId });
|
2024-04-29 19:06:11 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка получения списка планов обучения");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreatePlanOfStudy(PlanOfStudyBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка создания плана обучения");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-27 17:32:21 +04:00
|
|
|
|
[HttpPost]
|
2024-04-29 19:06:11 +04:00
|
|
|
|
public void UpdatePlanOfStudy(PlanOfStudyBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка обновления плана обучения");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-27 17:32:21 +04:00
|
|
|
|
[HttpPost]
|
2024-04-29 19:06:11 +04:00
|
|
|
|
public void DeletePlanOfStudy(PlanOfStudyBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.Delete(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка удаления плана обучения");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|