96 lines
2.5 KiB
C#
96 lines
2.5 KiB
C#
using CandidateReviewContracts.BindingModels;
|
|
using CandidateReviewContracts.BusinessLogicsContracts;
|
|
using CandidateReviewContracts.SearchModels;
|
|
using CandidateReviewContracts.ViewModels;
|
|
using CandidateReviewDataModels.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace CandidateReviewRestApi.Controllers
|
|
{
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
public class CriterionController : Controller
|
|
{
|
|
private readonly ILogger _logger;
|
|
private readonly ICriterionLogic _logic;
|
|
public CriterionController(ICriterionLogic logic, ILogger<CriterionController> logger)
|
|
{
|
|
_logger = logger;
|
|
_logic = logic;
|
|
}
|
|
|
|
[HttpGet]
|
|
public CriterionViewModel? Details(int id)
|
|
{
|
|
try
|
|
{
|
|
return _logic.ReadElement(new CriterionSearchModel
|
|
{
|
|
Id = id
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка получения критерия");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
public List<CriterionViewModel>? List()
|
|
{
|
|
try
|
|
{
|
|
return _logic.ReadList(null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка получения списка критериев");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Create(CriterionBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Create(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка создания критерия");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Update(CriterionBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Update(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка обновления критерия");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Delete(CriterionBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Delete(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка удаления критерия");
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|