35c5e1af28
Added role based authentication to contollers
35 lines
851 B
C#
35 lines
851 B
C#
using Microsoft.AspNet.Identity;
|
|
using RMDataManagerLibrary.DataAcccess;
|
|
using RMDataManagerLibrary.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
|
|
namespace RMDataManager.Controllers
|
|
{
|
|
|
|
public class SaleController : ApiController
|
|
{
|
|
[Authorize(Roles = "Cashier")]
|
|
public void Post(SaleModel sale)
|
|
{
|
|
string cashierId = RequestContext.Principal.Identity.GetUserId();
|
|
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();
|
|
}
|
|
}
|
|
}
|