PIbd-22_Fedorenko_Puchkina_.../LawFim/LawFirmRestApi/Controllers/CaseController.cs

165 lines
4.2 KiB
C#
Raw Normal View History

2024-04-29 11:36:49 +04:00
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.Design;
namespace LawFirmRestApi.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, ClientViewModel> model)
{
try
{
_logic.AddClientToCase(model.Item1, model.Item2);
}
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;
}
}
}
}