34 lines
885 B
C#
34 lines
885 B
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using RMDataManagerLibrary.DataAcccess;
|
|
using RMDataManagerLibrary.Models;
|
|
using System.Security.Claims;
|
|
|
|
namespace RMApi.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class SaleController : ControllerBase
|
|
{
|
|
[Authorize(Roles = "Cashier")]
|
|
public void Post(SaleModel sale)
|
|
{
|
|
string cashierId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
SaleData data = new SaleData();
|
|
|
|
data.SaveSale(sale, cashierId);
|
|
}
|
|
|
|
[Authorize(Roles = "Admin,Manager")]
|
|
[Route("GetSalesReport")]
|
|
public List<SaleReportModel> GetSalesReport()
|
|
{
|
|
SaleData data = new SaleData();
|
|
|
|
return data.GetSaleReport();
|
|
}
|
|
}
|
|
}
|