我需要确定用户是否只是销售员。我的 ASP.NET MVC 4 Controller 中有以下内容:
public ActionResult Index() {
string salespersonCode = null;
var roles = Roles.GetRolesForUser();
if(roles.Count() == 1 && roles.Contains(UserRoles.Salesperson.ToString()))
salespersonCode = User.Name();
return View(new ProspectIndexViewModel { Prospects = _crmService.GetActiveProspects(salespersonCode) });
}
用户可能有多个角色。如果用户只有该角色,我想将返回的数据限制为仅属于销售人员的数据。其他三个角色(Manager、Admin 和 SalesAdministrator)应接收整个列表。谢谢!
请您参考如下方法:
