100 lines
2.7 KiB
C#
100 lines
2.7 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 AssessmentController : Controller
|
|
{
|
|
private readonly ILogger _logger;
|
|
private readonly IAssessmentLogic _logic;
|
|
public AssessmentController(IAssessmentLogic logic, ILogger<AssessmentController> logger)
|
|
{
|
|
_logger = logger;
|
|
_logic = logic;
|
|
}
|
|
|
|
[HttpGet]
|
|
public AssessmentViewModel? Details(int id)
|
|
{
|
|
try
|
|
{
|
|
return _logic.ReadElement(new AssessmentSearchModel
|
|
{
|
|
UserId = id
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка получения оценки");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
public List<AssessmentViewModel>? ListByResumeId(int id)
|
|
{
|
|
try
|
|
{
|
|
return _logic.ReadList(new AssessmentSearchModel
|
|
{
|
|
ResumeId = id
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка получения оценок");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Create(AssessmentBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
int? id = _logic.Create(model);
|
|
return Ok(new AssessmentBindingModel { Id = (int)id });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка создания оценки");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Update(AssessmentBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Update(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка обновления оценки");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Delete(AssessmentBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Delete(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка удаления оценки");
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|