86 lines
1.3 KiB
C#
86 lines
1.3 KiB
C#
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 DealController : Controller
|
|
{
|
|
private readonly IDealLogic _logic;
|
|
|
|
public DealController(IDealLogic logic)
|
|
{
|
|
_logic = logic;
|
|
}
|
|
|
|
[HttpGet]
|
|
public DealViewModel? Get(int id)
|
|
{
|
|
try
|
|
{
|
|
return _logic.ReadElement(new DealSearchModel { Id = id });
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
public List<DealViewModel>? GetAllByUser(int userId)
|
|
{
|
|
try
|
|
{
|
|
return _logic.ReadList(null);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Create(DealBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Create(model);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Update(DealBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Update(model);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Delete(DealBindingModel model)
|
|
{
|
|
try
|
|
{
|
|
_logic.Delete(new() { Id = model.Id });
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|