2024-05-02 15:12:31 +04:00
|
|
|
|
using LawCompanyContracts.BindingModels;
|
|
|
|
|
using LawCompanyContracts.BusinessLogicContracts;
|
|
|
|
|
using LawCompanyContracts.SearchModels;
|
|
|
|
|
using LawCompanyContracts.ViewModels;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.ComponentModel.Design;
|
|
|
|
|
|
|
|
|
|
namespace LawCompanyRestApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class CaseController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly ICaseLogic _logic;
|
|
|
|
|
private readonly IClientLogic _clientlogic;
|
|
|
|
|
|
|
|
|
|
public CaseController(ICaseLogic logic, ILogger<CaseController> logger, IClientLogic clientlogic)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_logic = logic;
|
|
|
|
|
_clientlogic = clientlogic;
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<CaseViewModel>? GetCaseList(int executorId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _logic.ReadList(new CaseSearchModel
|
|
|
|
|
{
|
|
|
|
|
ExecutorId = executorId
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 02:47:37 +04:00
|
|
|
|
[HttpGet("{id}")]
|
|
|
|
|
public CaseViewModel? GetCase(int id)
|
2024-05-02 15:12:31 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-05-27 02:47:37 +04:00
|
|
|
|
return _logic.ReadElement(new CaseSearchModel { Id = id, });
|
2024-05-02 15:12:31 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2024-05-27 02:47:37 +04:00
|
|
|
|
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
2024-05-02 15:12:31 +04:00
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2024-05-27 02:47:37 +04:00
|
|
|
|
public void CreateCase(CaseBindingModel model)
|
2024-05-02 15:12:31 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
2024-05-27 02:47:37 +04:00
|
|
|
|
_logic.CreateCase(model);
|
2024-05-02 15:12:31 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2024-05-27 02:47:37 +04:00
|
|
|
|
public void UpdateCase(CaseBindingModel model)
|
2024-05-02 15:12:31 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-05-27 02:47:37 +04:00
|
|
|
|
_logic.Update(model);
|
2024-05-02 15:12:31 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2024-05-27 02:47:37 +04:00
|
|
|
|
|
2024-05-02 15:12:31 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteCase(CaseBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_logic.DeleteCase(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<ClientViewModel>? GetClientListToCase(int caseId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _clientlogic.ReadCaseElementList(new CaseSearchModel
|
|
|
|
|
{
|
|
|
|
|
Id = caseId
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|