当前位置: 首页>>代码示例>>C#>>正文


C# UserProfile.AspNetIdentityUserIsInRoleSystemAdmin方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:berlstone,项目名称:GStore,代码行数:54,代码来源:GStoreAuthorizationExtensions.cs

示例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();
     }
 }
开发者ID:berlstone,项目名称:GStore,代码行数:24,代码来源:AdminMenuViewModel.cs


注:本文中的UserProfile.AspNetIdentityUserIsInRoleSystemAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。