public async Task StoreAsync(Model.IdentityResource model) { var entity = model.ToEntity(); try { await StorageContext.SaveBlobWithHashedKeyAsync(entity.Name, JsonConvert.SerializeObject(entity), StorageContext.IdentityResourceBlobContainer); var entities = await GetAllIdentityResourceEntitiesAsync(); entities = entities.Where(e => entity.Name != e.Name).Concat(new Entities.IdentityResource[] { entity }); await UpdateIdentityResourceCacheFileAsync(entities); } 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; } }
public async Task <bool> AddIdentityResource(IdentityServer4.Models.IdentityResource resource) { bool Result = false; await Context.IdentityResources.AddAsync(resource.ToEntity()); Result = await Context.SaveChangesAsync() > 0; return(Result); }
private async Task <IdentityServer4.Models.IdentityResource> CreateIdentityResource(string name, string displayName, bool emphasize, List <string> claimTypes) { var identityResource = new IdentityServer4.Models.IdentityResource(name, displayName, claimTypes); identityResource.Emphasize = emphasize; _configurationContext.IdentityResources.Add(identityResource.ToEntity()); try { await _configurationContext.SaveChangesAsync(); return(identityResource); } catch (Exception) { return(null); } }
public async Task StoreAsync(Model.IdentityResource model) { var entity = model.ToEntity(); try { await StorageContext.SaveBlobAsync(entity.Name, JsonConvert.SerializeObject(entity), StorageContext.IdentityResourceBlobContainer); } 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; } }