2023-05-18 00:43:44 +04:00
|
|
|
|
using CaseAccountingBusinessLogic.BusinessLogics;
|
|
|
|
|
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 SpecializationController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ISpecializationLogic specializationLogic;
|
|
|
|
|
|
|
|
|
|
public SpecializationController(ISpecializationLogic logic)
|
|
|
|
|
{
|
|
|
|
|
specializationLogic = logic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public SpecializationViewModel? Get(int id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return specializationLogic.ReadElement(new SpecializationSearchModel { Id = id });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<SpecializationViewModel>? GetAllByUser(int userId)
|
2023-05-18 23:42:48 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return specializationLogic.ReadList(new SpecializationSearchModel { UserId = userId }) ;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public List<SpecializationViewModel>? GetAll()
|
2023-05-18 00:43:44 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return specializationLogic.ReadList(null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 23:42:48 +04:00
|
|
|
|
|
2023-05-18 00:43:44 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Create(SpecializationBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
specializationLogic.Create(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Update(SpecializationBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
specializationLogic.Update(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Delete(SpecializationBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
specializationLogic.Delete(new() { Id = model.Id });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|