public async Task StoreAsync(Model.ApiScope model)
        {
            var entity = model.ToEntity();

            try
            {
                await StorageContext
                .SaveBlobWithHashedKeyAsync(entity.Name, JsonConvert.SerializeObject(entity), StorageContext.ApiScopeBlobContainer)
                .ConfigureAwait(false);

                var entities = await GetAllApiScopeEntitiesAsync().ConfigureAwait(false);

                entities = entities.Where(e => entity.Name != e.Name).Concat(new Entities.ApiScope[] { entity });
                await UpdateApiScopeCacheFileAsync(entities).ConfigureAwait(false);
            }
            catch (AggregateException agg)
            {
                ExceptionHelper.LogStorageExceptions(agg, (tblEx) =>
                {
                    _logger.LogWarning("exception updating {apiName} identity resource in table storage: {error}", model.Name, tblEx.Message);
                }, (blobEx) =>
                {
                    _logger.LogWarning("exception updating {apiName} identity resource in blob storage: {error}", model.Name, blobEx.Message);
                });
                throw;
            }
        }
Esempio n. 2
0
        public async Task <bool> AddApiScope(IdentityServer4.Models.ApiScope scope)
        {
            bool Result = false;
            await Context.ApiScopes.AddAsync(scope.ToEntity());

            Result = await Context.SaveChangesAsync() > 0;

            return(Result);
        }