示例#1
0
        public async Task <int> AddApiScopeAsync(ApiScopesDto apiScope)
        {
            var canInsert = await CanInsertApiScopeAsync(apiScope);

            if (!canInsert)
            {
                await BuildApiScopesViewModel(apiScope);

                throw new UserFriendlyViewException(string.Format(_apiResourceServiceResources.ApiScopeExistsValue().Description, apiScope.Name), _apiResourceServiceResources.ApiScopeExistsKey().Description, apiScope);
            }

            var scope = apiScope.ToEntity();

            return(await _apiResourceRepository.AddApiScopeAsync(apiScope.ApiResourceId, scope));
        }
示例#2
0
        public virtual async Task <int> AddApiScopeAsync(ApiScopesDto apiScope)
        {
            var canInsert = await CanInsertApiScopeAsync(apiScope);

            if (!canInsert)
            {
                await BuildApiScopesViewModelAsync(apiScope);

                throw new UserFriendlyViewException(string.Format(ApiResourceServiceResources.ApiScopeExistsValue().Description, apiScope.Name), ApiResourceServiceResources.ApiScopeExistsKey().Description, apiScope);
            }

            var scope = apiScope.ToEntity();

            var added = await ApiResourceRepository.AddApiScopeAsync(apiScope.ApiResourceId, scope);

            await AuditEventLogger.LogEventAsync(new ApiScopeAddedEvent(apiScope));

            return(added);
        }