83 lines
2.1 KiB
C#
83 lines
2.1 KiB
C#
|
using LawFirmContracts.BindingModels;
|
|||
|
using LawFirmContracts.BusinessLogicContracts;
|
|||
|
using LawFirmContracts.SearchModels;
|
|||
|
using LawFirmContracts.ViewModels;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using System.Diagnostics;
|
|||
|
|
|||
|
namespace LawFirmRestApi.Controllers
|
|||
|
{
|
|||
|
[Route("api/[controller]/[action]")]
|
|||
|
[ApiController]
|
|||
|
public class ClientController : Controller
|
|||
|
{
|
|||
|
private readonly ILogger _logger;
|
|||
|
private readonly IClientLogic _logic;
|
|||
|
|
|||
|
public ClientController(IClientLogic logic, ILogger<ClientController> logger)
|
|||
|
{
|
|||
|
_logger = logger;
|
|||
|
_logic = logic;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
[HttpGet]
|
|||
|
public List<ClientViewModel>? GetClientList(int executorId)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
return _logic.ReadList(new ClientSearchModel { ExecutorId = executorId });
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
|||
|
throw;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[HttpPost]
|
|||
|
public void CreateClient(ClientBindingModel model)
|
|||
|
{
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
_logic.Create(model);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|||
|
throw;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
[HttpPost]
|
|||
|
public void UpdateClient(ClientBindingModel model)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
_logic.Update(model);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|||
|
throw;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[HttpPost]
|
|||
|
public void DeleteClient(ClientBindingModel model)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
_logic.Delete(model);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|||
|
throw;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|