2023-05-18 00:43:44 +04:00
|
|
|
|
using CaseAccountingContracts.BindingModels;
|
|
|
|
|
using CaseAccountingContracts.BusinessLogicContracts;
|
|
|
|
|
using CaseAccountingContracts.SearchModels;
|
|
|
|
|
using CaseAccountingContracts.ViewModels;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace CaseAccountingRestApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class LawyerController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILawyerLogic lawyerLogic;
|
|
|
|
|
|
2023-05-19 14:53:49 +04:00
|
|
|
|
private readonly ICaseLogic _caseLogic;
|
|
|
|
|
|
|
|
|
|
public LawyerController(ILawyerLogic logic, ICaseLogic caseLogic)
|
2023-05-18 00:43:44 +04:00
|
|
|
|
{
|
|
|
|
|
lawyerLogic = logic;
|
2023-05-19 14:53:49 +04:00
|
|
|
|
_caseLogic = caseLogic;
|
2023-05-18 00:43:44 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public LawyerViewModel? Get(int id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return lawyerLogic.ReadElement(new LawyerSearchModel { Id = id });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<LawyerViewModel>? GetAllByUser(int userId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return lawyerLogic.ReadList(null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Create(LawyerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lawyerLogic.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Update(LawyerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lawyerLogic.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Delete(LawyerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lawyerLogic.Delete(new() { Id = model.Id });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-19 14:53:49 +04:00
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2023-05-19 21:27:33 +04:00
|
|
|
|
public List<CaseViewModel>? GetAllCases()
|
2023-05-19 14:53:49 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _caseLogic.ReadList(null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<LawyerViewModel>? GetAllByUserAndSpecialization(int userId, int specialization)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return lawyerLogic.ReadList(new LawyerSearchModel { UserId = userId, SpecializationId = specialization });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-18 00:43:44 +04:00
|
|
|
|
}
|
|
|
|
|
}
|