public async Task ToggleResourceIdAccess(string policyName, TTenantKey tenantId, bool isRequired, IMultiTenantIamProviderCache <TTenantKey> cache) { var policyId = await CreateOrGetPolicy(policyName); var policy = await _context.IamPolicyResourceIds .FirstOrDefaultAsync(x => x.Id.Equals(policyId) && x.TenantId.Equals(tenantId)); if (policy == null) { _context.IamPolicyResourceIds.Add(new Model.MultiTenantPolicyResourceId <TKey, TTenantKey>() { PolicyId = policyId, TenantId = tenantId, RequiresResourceIdAccess = isRequired }); } else { policy.RequiresResourceIdAccess = isRequired; } await _context.SaveChangesAsync(); cache.ToggleResourceIdAccess(policyName, tenantId, isRequired); }
async Task <IdentityResult> IMultiTenantRoleClaimStore <TRole, TTenantKey> .UpdateAsync(TRole role, CancellationToken cancellationToken) { IdentityResult ret = IdentityResult.Success; if (role == null) { throw new ArgumentNullException(nameof(role)); } _context.Attach(role); role.ConcurrencyStamp = Guid.NewGuid().ToString(); _context.Update(role); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { ret = IdentityResult.Failed(new IdentityErrorDescriber().ConcurrencyFailure()); } return(ret); }