diff --git a/LawFim/LawFirmRestApi/Controllers/ConsultationController.cs b/LawFim/LawFirmRestApi/Controllers/ConsultationController.cs new file mode 100644 index 0000000..40c6451 --- /dev/null +++ b/LawFim/LawFirmRestApi/Controllers/ConsultationController.cs @@ -0,0 +1,115 @@ +using LawFirmBusinessLogic.BusinessLogics; +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace LawFirmRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ConsultationController : Controller + { + private readonly ILogger _logger; + private readonly IConsultationLogic _logic; + private readonly ILawyerLogic _lawyerlogic; + + public ConsultationController(IConsultationLogic logic, ILogger + logger, ILawyerLogic lawyerLogic) + { + _logger = logger; + _logic = logic; + _lawyerlogic = lawyerLogic; + + } + [HttpGet] + public List? GetConsultationList(int guarantorId) + { + try + { + return _logic.ReadList(new ConsultationSearchModel + { + GuarantorId= guarantorId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка консультаций"); + throw; + } + } + + [HttpPost] + public void CreateConsultation(ConsultationBindingModel model) + { + + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания кунсультации"); + throw; + } + + } + [HttpPost] + public void UpdateConsultation(ConsultationBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления консультации"); + throw; + } + } + [HttpPost] + public void DeleteConsultation(ConsultationBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления консультации"); + throw; + } + } + [HttpPost] + public void AddLawyerToConsultation(Tuple model) + { + try + { + var modelLawyer = _lawyerlogic.ReadElement(new LawyerSearchModel { Id = model.Item2 }); + if (modelLawyer != null) { _logic.AddLawyerToConsultation(model.Item1, modelLawyer); } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка добавления юристов в консультацию"); + throw; + } + } + [HttpGet] + public List? GetLawyerListToConsultation(int conId) + { + try + { + return _lawyerlogic.ReadConsultationElementList(new ConsultationSearchModel + { + Id = conId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка юристов консультации"); + throw; + } + } + } +} diff --git a/LawFim/LawFirmRestApi/Controllers/GuarantorController.cs b/LawFim/LawFirmRestApi/Controllers/GuarantorController.cs new file mode 100644 index 0000000..1620efc --- /dev/null +++ b/LawFim/LawFirmRestApi/Controllers/GuarantorController.cs @@ -0,0 +1,69 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace LawFirmRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class GuarantorController : Controller + { + private readonly ILogger _logger; + private readonly IGuarantorLogic _logic; + + public GuarantorController(IGuarantorLogic logic, ILogger logger) + { + _logger = logger; + _logic = logic; + + } + [HttpGet] + public GuarantorViewModel? Login(string fio, string login, string password) + { + try + { + return _logic.ReadElement(new GuarantorSearchModel + { + FIO = fio, + Email = login, + Password = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + [HttpPost] + public void Register(GuarantorBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка регистрации"); + throw; + } + + } + [HttpPost] + public void UpdateData(GuarantorBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления данных"); + throw; + } + } + } +} diff --git a/LawFim/LawFirmRestApi/Controllers/HearingController.cs b/LawFim/LawFirmRestApi/Controllers/HearingController.cs new file mode 100644 index 0000000..af246f3 --- /dev/null +++ b/LawFim/LawFirmRestApi/Controllers/HearingController.cs @@ -0,0 +1,115 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace LawFirmRestApi.Controllers +{ + + [Route("api/[controller]/[action]")] + [ApiController] + public class HearingController : Controller + { + private readonly ILogger _logger; + private readonly IHearingLogic _logic; + private readonly ILawyerLogic _lawyerlogic; + + public HearingController(IHearingLogic logic, ILogger + logger, ILawyerLogic lawyerlogic) + { + _logger = logger; + _logic = logic; + _lawyerlogic = lawyerlogic; + } + [HttpGet] + public List? GetHearingList(int guarantorId) + { + try + { + return _logic.ReadList(new HearingSearchModel + { + GuarantorId = guarantorId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка слушаний"); + throw; + } + } + + [HttpPost] + public void CreateHearing(HearingBindingModel model) + { + + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания слушания"); + throw; + } + + } + [HttpPost] + public void UpdateHearing(HearingBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления слушания"); + throw; + } + } + [HttpPost] + public void DeleteHearing(HearingBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления слушания"); + throw; + } + } + [HttpPost] + public void AddLawyerToHearing(Tuple model) + { + try + { + var modelLawyer = _lawyerlogic.ReadElement(new LawyerSearchModel { Id = model.Item2 }); + if (modelLawyer != null) { _logic.AddLawyerToHearing(model.Item1, modelLawyer); } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка добавления юриста в слушание"); + throw; + } + } + [HttpGet] + public List? GetLawyerListToHearing(int hearingId) + { + try + { + return _lawyerlogic.ReadHearingElementList(new HearingSearchModel + { + Id = hearingId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка юристов слушания"); + throw; + } + } + } +} diff --git a/LawFim/LawFirmRestApi/Controllers/LawyerController.cs b/LawFim/LawFirmRestApi/Controllers/LawyerController.cs new file mode 100644 index 0000000..2afcd0f --- /dev/null +++ b/LawFim/LawFirmRestApi/Controllers/LawyerController.cs @@ -0,0 +1,79 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace LawFirmRestApi.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; + } + } + } +}