public async Task <bool> Execute(string scopeName)
        {
            _managerEventSource.StartToRemoveScope(scopeName);
            if (string.IsNullOrWhiteSpace(scopeName))
            {
                throw new ArgumentNullException(nameof(scopeName));
            }

            var scope = await _scopeRepository.GetAsync(scopeName);

            if (scope == null)
            {
                throw new IdentityServerManagerException(ErrorCodes.InvalidRequestCode,
                                                         string.Format(ErrorDescriptions.TheScopeDoesntExist, scopeName));
            }

            var res = await _scopeRepository.DeleteAsync(scope);

            if (res)
            {
                _managerEventSource.FinishToRemoveScope(scopeName);
            }

            return(res);
        }
Пример #2
0
        public async Task <bool> Execute(Scope scope)
        {
            if (scope == null)
            {
                throw new ArgumentNullException(nameof(scope));
            }

            if (await _scopeRepository.GetAsync(scope.Name) == null)
            {
                throw new IdentityServerManagerException(
                          ErrorCodes.InvalidParameterCode,
                          string.Format(ErrorDescriptions.TheScopeDoesntExist, scope.Name));
            }

            return(await _scopeRepository.UpdateAsync(scope));
        }
        public async Task <Scope> Execute(string scopeName)
        {
            if (string.IsNullOrWhiteSpace(scopeName))
            {
                throw new ArgumentNullException(nameof(scopeName));
            }

            var result = await _scopeRepository.GetAsync(scopeName);

            if (result == null)
            {
                throw new IdentityServerManagerException(ErrorCodes.InvalidRequestCode,
                                                         string.Format(ErrorDescriptions.TheScopeDoesntExist, scopeName));
            }

            return(result);
        }