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); } }
public void Register(string name, string displayName) { if (!_apiScopeRepository.GetAll().Any(e => e.Name == name)) { ApiScope apiScope = new ApiScope(name); apiScope.SetDisplayName(displayName ?? name); _apiScopeRepository.Insert(apiScope); } }
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); } }