public async Task <TResult> UpdateClaims <TResult, TResultAdded>(Guid authorizationId, UpdateClaimsSuccessDelegateAsync <TResult, TResultAdded> onSuccess, Func <TResultAdded> addedSuccess, Func <TResultAdded> addedFailure, Func <TResult> notFound, Func <string, TResult> failure) { return(await repository.UpdateAsync <Documents.AuthorizationDocument, TResult>(authorizationId, async (authorizationDocument, save) => { var claims = await authorizationDocument.GetClaims(repository); var result = await onSuccess(claims, async(claimId, issuer, type, value) => { var claimDoc = new Documents.ClaimDocument() { ClaimId = claimId, Issuer = issuer == default(Uri) ? default(string) : issuer.AbsoluteUri, Type = type == default(Uri) ? default(string) : type.AbsoluteUri, Value = value, }; return await await authorizationDocument.AddClaimsAsync(claimDoc, repository, async() => { await save(authorizationDocument); return addedSuccess(); }, () => Task.FromResult(addedFailure())); }); return result; }, () => notFound())); }
internal async Task <TResult> AddClaimsAsync <TResult>(ClaimDocument claimsDoc, AzureStorageRepository repository, Func <TResult> success, Func <TResult> failure) { var claimDocumentIdsCurrent = Claims.ToGuidsFromByteArray(); var claimDocumentIds = claimDocumentIdsCurrent.Concat(new Guid[] { claimsDoc.ClaimId }); this.Claims = claimDocumentIds.ToByteArrayOfGuids(); return(await repository.CreateAsync(claimsDoc.ClaimId, claimsDoc, () => success(), () => failure())); }