using LawCompanyContracts.BindingModels; using LawCompanyContracts.BusinessLogicContracts; using LawCompanyContracts.SearchModels; using LawCompanyContracts.ViewModels; using Microsoft.AspNetCore.Mvc; namespace LawCompanyRestApi.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class LawyerController : Controller { private readonly ILogger _logger; private readonly ILawyerLogic _logic; public LawyerController(ILawyerLogic logic, ILogger logger) { _logger = logger; _logic = logic; } [HttpGet] public List? GetLawyerList(int guarantorId) { try { return _logic.ReadList(new LawyerSearchModel { GuarantorId = guarantorId }); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения списка юристов"); throw; } } [HttpPost] public void CreateLawyer(LawyerBindingModel model) { try { _logic.Create(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка создания юриста"); throw; } } [HttpPost] public void UpdateLawyer(LawyerBindingModel model) { try { _logic.Update(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка обновления юриста"); throw; } } [HttpPost] public void DeleteLawyer(LawyerBindingModel model) { try { _logic.Delete(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка удаления юриста"); throw; } } } }