Exemplo n.º 1
0
        public void Register(string name, string displayName)
        {
            if (!ApiScopeRepository.GetAll().Any(e => e.Name == name))
            {
                Permission scopeManagePermission = new Permission(name + ApiManageScope.NamePostfix)
                {
                    DisplayName = (displayName ?? name) + "域权限" + ApiManageScope.DisplayNamePostfix
                };
                _permissionManager.Create(scopeManagePermission);
                Permission queryManagePermission = new Permission(name + ApiQueryScope.NamePostfix)
                {
                    DisplayName = (displayName ?? name) + "域权限" + ApiQueryScope.DisplayNamePostfix
                };
                _permissionManager.Create(queryManagePermission);

                ApiScope apiScope = new ApiScope(name);

                apiScope.SetDisplayName(displayName ?? name);

                apiScope.ApiManageScope.AddPermission(scopeManagePermission);
                apiScope.ApiQueryScope.AddPermission(scopeManagePermission);
                apiScope.ApiQueryScope.AddPermission(queryManagePermission);

                ApiScopeRepository.Insert(apiScope);
            }
        }
Exemplo n.º 2
0
        public void Register(string name, string displayName, List <Permission> managePermissions, List <Permission> queryPermissions)
        {
            if (!ApiScopeRepository.GetAll().Any(e => e.Name == name))
            {
                ApiScope apiScope = new ApiScope(name);

                apiScope.SetDisplayName(displayName ?? name);

                managePermissions.ForEach(item => apiScope.ApiManageScope.AddPermission(item));
                queryPermissions.ForEach(item => apiScope.ApiQueryScope.AddPermission(item));

                ApiScopeRepository.Insert(apiScope);
            }
        }
Exemplo n.º 3
0
 public IQueryable <ApiScope> GetApiScopes() => ApiScopeRepository.GetAll();
Exemplo n.º 4
0
 public ApiScope GetApiScopesForApiSingle(ApiSingle apiSingle)
 {
     return(ApiScopeRepository.GetAll().FirstOrDefault(e => e.ApiSingles.Where(ie => ie.Id == apiSingle.Id).Any()));
 }