58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SPiluSZharuContracts.AdapterContracts;
|
|
using SPiluSZharuContracts.BindingModels;
|
|
|
|
namespace SPiluSZharuWebApi.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
public class SalesController(ISaleAdapter adapter) : ControllerBase
|
|
{
|
|
private readonly ISaleAdapter _adapter = adapter;
|
|
|
|
[HttpGet]
|
|
public IActionResult GetRecords(DateTime fromDate, DateTime toDate)
|
|
{
|
|
return _adapter.GetList(fromDate, toDate).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetWorkerRecords(string id, DateTime fromDate, DateTime toDate)
|
|
{
|
|
return _adapter.GetWorkerList(id, fromDate, toDate).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetRestaurantRecords(string id, DateTime fromDate, DateTime toDate)
|
|
{
|
|
return _adapter.GetRestaurantList(id, fromDate, toDate).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult GetProductRecords(string id, DateTime fromDate, DateTime toDate)
|
|
{
|
|
return _adapter.GetProductList(id, fromDate, toDate).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpGet("{data}")]
|
|
public IActionResult GetRecord(string data)
|
|
{
|
|
return _adapter.GetElement(data).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Sale([FromBody] SaleBindingModel model)
|
|
{
|
|
return _adapter.MakeSale(model).GetResponse(Request, Response);
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public IActionResult Cancel(string id)
|
|
{
|
|
return _adapter.CancelSale(id).GetResponse(Request, Response);
|
|
}
|
|
}
|