using CandidateReviewContracts.BindingModels; using CandidateReviewContracts.BusinessLogicsContracts; using CandidateReviewContracts.SearchModels; using CandidateReviewContracts.ViewModels; using CandidateReviewDataModels.Models; using Microsoft.AspNetCore.Mvc; using System.Linq; namespace CandidateReviewRestApi.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class CompanyController : Controller { private readonly ILogger _logger; private readonly ICompanyLogic _logic; private readonly IVacancyLogic _vacancyLogic; public CompanyController(ICompanyLogic logic, IVacancyLogic vacancyLogic, ILogger logger) { _logger = logger; _logic = logic; _vacancyLogic = vacancyLogic; } [HttpGet] public CompanyViewModel? Profile(int id) { try { return _logic.ReadElement(new CompanySearchModel { Id = id }); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения профиля компании"); throw; } } [HttpPost] public int Create(CompanyBindingModel model) { try { int newCompanyId = _logic.Create(model); return newCompanyId; } catch (Exception ex) { _logger.LogError(ex, "Ошибка создания профиля компании"); throw; } } [HttpPost] public void Update(CompanyBindingModel model) { try { _logic.Update(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка обновления профиля компании"); throw; } } [HttpDelete] public void Delete(CompanyBindingModel model) { try { _logic.Delete(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка удаления профиля компании"); throw; } } } }