//Admin Can see all user data //Dealer can see only dealer data associated with dealer username //[Authorize(Roles="Admin")] public ActionResult Index() { //By Default user is not an admin user Boolean IsAdmin = false; //Check if the user is an admin user if (Roles.IsUserInRole(User.Identity.Name, "Admin")) { IsAdmin = true; } //Create an object for the commission model CommissionModel Commissions = new CommissionModel(); //Get the commission result, if an admin then retrive all data and if dealer then get the data associated with username var result = Commissions.GetCommission(User.Identity.Name, IsAdmin); //List<Havas_Exercise.Models.CommissionModel> C = result.ToList(); return(View(result)); }
public ActionResult Index(DateTime?StartDate = null, DateTime?EndDate = null, int PaymentStatus = 0) { //By default user is not an admin user Boolean IsAdmin = false; //Check if the user is logged in as admin user if (Roles.IsUserInRole(User.Identity.Name, "Admin")) { IsAdmin = true; } //Create a commission model CommissionModel Commissions = new CommissionModel(); //Passing the value to the method var result = Commissions.GetCommission(User.Identity.Name, IsAdmin, StartDate, EndDate, PaymentStatus); //List<Havas_Exercise.Models.CommissionModel> C = result.ToList(); //pass the result to view which is a Index view return(View(result)); }