165 lines
3.2 KiB
C#
165 lines
3.2 KiB
C#
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;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void CreateCase(CaseBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
|
|
_logic.CreateCase(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
throw;
|
|
}
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
public void UpdateCase(CaseBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Update(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
throw;
|
|
}
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
public void AnalysisCase(CaseBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
//возможно переделаю метод
|
|
_logic.CaseAnalysis(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void HearingCase(CaseBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
//возможно переделаю метод
|
|
_logic.CaseHearing(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void CloseCase(CaseBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
|
|
_logic.CloseCase(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void DeleteCase(CaseBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
|
|
_logic.DeleteCase(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка создания заказа");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void AddClientToCase(Tuple<CaseSearchModel, int> model)
|
|
{
|
|
try
|
|
{
|
|
var modelClient = _clientlogic.ReadElement(new ClientSearchModel { Id = model.Item2 });
|
|
if (modelClient != null) _logic.AddClientToCase(model.Item1, modelClient);
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|