What I am trying to do is filter a query based on the role of the logged in user in my MVC3 Controller. I am restricting users to have only one role; no user can have more than one role. I have some code snippets but I am not sure this is the way to go. And also if someone can assist me to achieve my goal
string[] roles = Roles.GetRolesForUser();
string color= roles[0];
string vcolor = color.Substring(0, 4);
switch (vcolor)
{
case "Rewa":
vcolor = "white";
break;
case "Ukau":
vcolor == "black";
break;
case "Whau":
vcolor = "green";
break;
case "Angi":
vcolor = "Blue";
break;
}
public ActionResult _MembersView()
{
var pagenew = db.Members
.Where(u => u.color == vcolor)(I will want to then set this condition to the vcolor dynamically)
.OrderBy(u => u.Tcd);
//.Take(12);
return PartialView(pagenew);
}