2023-05-19 14:39:49 +04:00
|
|
|
|
using CaseAccountingBusinessLogic.BusinessLogics;
|
|
|
|
|
using CaseAccountingContracts.BindingModels;
|
2023-05-17 23:28:43 +04:00
|
|
|
|
using CaseAccountingContracts.BusinessLogicContracts;
|
|
|
|
|
using CaseAccountingContracts.SearchModels;
|
|
|
|
|
using CaseAccountingContracts.ViewModels;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace CaseAccountingRestApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class CaseController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ICaseLogic _logic;
|
2023-05-19 14:39:49 +04:00
|
|
|
|
private readonly ISpecializationLogic _specializationLogic;
|
2023-05-17 23:28:43 +04:00
|
|
|
|
|
2023-05-19 14:39:49 +04:00
|
|
|
|
public CaseController(ICaseLogic logic, ISpecializationLogic specializationLogic)
|
2023-05-17 23:28:43 +04:00
|
|
|
|
{
|
|
|
|
|
_logic = logic;
|
2023-05-19 14:39:49 +04:00
|
|
|
|
_specializationLogic = specializationLogic;
|
2023-05-17 23:28:43 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public CaseViewModel? Get(int id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _logic.ReadElement(new CaseSearchModel { Id = id });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<CaseViewModel>? GetAllByUser(int userId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-18 01:15:02 +04:00
|
|
|
|
return _logic.ReadList(new CaseSearchModel { UserId = userId });
|
2023-05-17 23:28:43 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 14:39:49 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<SpecializationViewModel>? GetAllSpecializations()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _specializationLogic.ReadList(null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 23:28:43 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Create(CaseBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Update(CaseBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Delete(CaseBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.Delete(new() { Id = model.Id });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|