本文整理汇总了C#中UserProfile.AspNetIdentityUserIsInRoleSystemAdmin方法的典型用法代码示例。如果您正苦于以下问题:C# UserProfile.AspNetIdentityUserIsInRoleSystemAdmin方法的具体用法?C# UserProfile.AspNetIdentityUserIsInRoleSystemAdmin怎么用?C# UserProfile.AspNetIdentityUserIsInRoleSystemAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserProfile
的用法示例。
在下文中一共展示了UserProfile.AspNetIdentityUserIsInRoleSystemAdmin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Authorization_IsAuthorized
/// <summary>
/// Checks multiple StoreFront permissions for the specified user
/// </summary>
/// <param name="storeFront"></param>
/// <param name="userProfile"></param>
/// <param name="allowAnyMatch">If allowAnyMatch is true, this is an OR test for each option. If allowAnyMatch = false, this is an AND test for all options</param>
/// <param name="actions"></param>
/// <returns></returns>
public static bool Authorization_IsAuthorized(this StoreFront storeFront, UserProfile userProfile, bool allowAnyMatch, params Identity.GStoreAction[] actions)
{
if (actions == null || actions.Count() == 0)
{
throw new ApplicationException("Authorization_IsAuthorized: no GStoreActions specified. You must call Authorization_IsAuthorized with one or more GStoreActions");
}
if (userProfile == null)
{
return false;
}
if (userProfile.AspNetIdentityUserIsInRoleSystemAdmin())
{
return true;
}
if (storeFront == null)
{
return false;
}
foreach (GStoreAction action in actions)
{
bool result = CheckSinglePermission(userProfile, storeFront, action);
if (allowAnyMatch && result)
{
//OR test, if one is true, return true
return true;
}
if (!allowAnyMatch && result == false)
{
//AND result, one is false, return false
return false;
}
}
if (allowAnyMatch)
{
//OR result, nothing matched
return false;
}
else
{
//AND result, all matched
return true;
}
}
示例2: AdminMenuViewModel
public AdminMenuViewModel(StoreFront storeFront, UserProfile userProfile, string currentArea)
{
this.UserProfile = userProfile;
if (currentArea.ToLower() != "blogadmin")
{
this.ShowBlogAdminLink = storeFront.ShowBlogAdminLink(userProfile);
}
if (currentArea.ToLower() != "catalogadmin")
{
this.ShowCatalogAdminLink = storeFront.ShowCatalogAdminLink(userProfile);
}
if (currentArea.ToLower() != "orderadmin")
{
this.ShowOrderAdminLink = storeFront.ShowOrderAdminLink(userProfile);
}
if (currentArea.ToLower() != "storeadmin")
{
this.ShowStoreAdminLink = storeFront.ShowStoreAdminLink(userProfile);
}
if (currentArea.ToLower() != "systemadmin")
{
this.ShowSystemAdminLink = userProfile.AspNetIdentityUserIsInRoleSystemAdmin();
}
}