I have a product with array of prices. I want that based on the user group the corresponding price will be displayed.
As far i created roles that are describing these groups
I would like somehow to get current users role.
Something like this:
public decimal Price {
get
{
var price = Prices.First(p => p.PriceType.Name == Something.CurentUser.Role);
return price;
}
}
You can write a conditional statement based on the name of each role. Based on if the user is a member of the role, execute a different LINQ statement.
if (User.IsInRole("Admin")) {
// ...
}
else if (User.IsInRole("UserPriceA")) {
// ...
}
else if (User.IsInRole("UserPriceB")) {
// ...
}
else if (User.IsInRole("UserPriceC")) {
// ...
}