80 lines
1.5 KiB
C#
80 lines
1.5 KiB
C#
|
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<LawyerController>
|
|||
|
logger)
|
|||
|
{
|
|||
|
_logger = logger;
|
|||
|
_logic = logic;
|
|||
|
|
|||
|
}
|
|||
|
[HttpGet]
|
|||
|
public List<LawyerViewModel>? 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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|