public virtual async Task <int> AddApiScopePropertyAsync(ApiScopePropertiesDto apiScopeProperties) { var canInsert = await CanInsertApiScopePropertyAsync(apiScopeProperties); if (!canInsert) { await BuildApiScopePropertiesViewModelAsync(apiScopeProperties); throw new UserFriendlyViewException(string.Format(ApiScopeServiceResources.ApiScopePropertyExistsValue().Description, apiScopeProperties.Key), ApiScopeServiceResources.ApiScopePropertyExistsKey().Description, apiScopeProperties); } var apiScopeProperty = apiScopeProperties.ToEntity(); var saved = await ApiScopeRepository.AddApiScopePropertyAsync(apiScopeProperties.ApiScopeId, apiScopeProperty); await AuditEventLogger.LogEventAsync(new ApiScopePropertyAddedEvent(apiScopeProperties)); return(saved); }