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)); }
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); }