public virtual async Task <int> UpdateApiScopeAsync(ApiScopeDto apiScope) { var canInsert = await CanInsertApiScopeAsync(apiScope); if (!canInsert) { throw new UserFriendlyViewException(string.Format(ApiScopeServiceResources.ApiScopeExistsValue().Description, apiScope.Name), ApiScopeServiceResources.ApiScopeExistsKey().Description, apiScope); } var scope = apiScope.ToEntity(); var originalApiScope = await GetApiScopeAsync(apiScope.Id); var updated = await ApiScopeRepository.UpdateApiScopeAsync(scope); await AuditEventLogger.LogEventAsync(new ApiScopeUpdatedEvent(originalApiScope, apiScope)); return(updated); }