public async Task <ScopeCreationResult> StartAsync(CreateScopeCommand command) { _isCompleted = true; if (await _repo.FindByScopeNameAsync(command.ScopeName) != null) { return(new ScopeCreationResult { Succeed = false, Message = $"Scope of scope name {command.ScopeName} already exists." }); } var scope = PermissionScope.Create(Guid.NewGuid(), command.ScopeName, command.DisplayName, command.Description); command.ClaimTypes.ToList().ForEach(s => scope.ClaimTypes.Add(s)); await _repo.AddAsync(scope); return(new ScopeCreationResult { Succeed = true, Message = $"Scope successfully created.", Id = scope.Id }); }
protected bool TryLoadScopes(string[] scopeNames, out IList <PermissionScope> scopes) { scopes = scopeNames.Select(sn => _scopeRepository.FindByScopeNameAsync(sn).Result).ToList(); return(scopes.All(s => s != null)); }