using CandidateReviewContracts.BindingModels; using CandidateReviewContracts.BusinessLogicsContracts; using CandidateReviewContracts.SearchModels; using CandidateReviewContracts.ViewModels; using Microsoft.AspNetCore.Mvc; namespace CandidateReviewRestApi.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class CompanyController : Controller { private readonly ILogger _logger; private readonly ICompanyLogic _logic; public CompanyController(ICompanyLogic logic, ILogger logger) { _logger = logger; _logic = logic; } [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; } } } }