public async Task UpdateReviewSetCustomer() { var key = $"UpdateReviewSetCustomer-{TestingUtility.RandomString()}"; await WithCustomer(client, async customer => { await WithUpdateableReview(client, reviewDraft => DefaultReviewDraftWithKey(reviewDraft, key), async review => { var updateActions = new List <UpdateAction <Review> >(); var setCustomerAction = new SetCustomerUpdateAction { Customer = customer.ToKeyResourceIdentifier() }; updateActions.Add(setCustomerAction); var updateCommand = new UpdateByKeyCommand <Review>(key, review.Version, updateActions); updateCommand.Expand(r => r.Customer); var updatedReview = await client.ExecuteAsync(updateCommand); Assert.NotNull(updatedReview.Customer.Obj); Assert.Equal(customer.Key, updatedReview.Customer.Obj.Key); return(updatedReview); }); }); }
public void UpdatePaymentByKeySetCustomer() { IClient commerceToolsClient = this.paymentsFixture.GetService <IClient>(); Payment payment = this.paymentsFixture.CreatePayment(); Assert.Null(payment.Customer); var customer = this.paymentsFixture.CreateCustomer(); var updateActions = new List <UpdateAction <Payment> >(); SetCustomerUpdateAction setCustomerUpdateAction = new SetCustomerUpdateAction { Customer = new Reference <Customer> { Id = customer.Id } }; updateActions.Add(setCustomerUpdateAction); Payment retrievedPayment = commerceToolsClient .ExecuteAsync(new UpdateByKeyCommand <Payment>(payment.Key, payment.Version, updateActions)) .Result; this.paymentsFixture.PaymentsToDelete.Add(retrievedPayment); Assert.NotNull(retrievedPayment.Customer); Assert.Equal(customer.Id, retrievedPayment.Customer.Id); }
public async Task UpdatePaymentByKeySetCustomer() { await WithCustomer(client, async customer => { await WithUpdateablePayment(client, async payment => { Assert.Null(payment.Customer); var action = new SetCustomerUpdateAction { Customer = customer.ToReference() }; var updatedPayment = await client .ExecuteAsync(payment.UpdateByKey(actions => actions.AddUpdate(action))); Assert.Equal(customer.Id, updatedPayment.Customer.Id); return(updatedPayment); }); }); }
public async Task UpdateShoppingListSetCustomer() { await WithCustomer(client, async customer => { await WithUpdateableShoppingList(client, async shoppingList => { var updateActions = new List <UpdateAction <ShoppingList> >(); var setCustomerAction = new SetCustomerUpdateAction { Customer = customer.ToKeyResourceIdentifier() }; updateActions.Add(setCustomerAction); var updateCommand = new UpdateByIdCommand <ShoppingList>(shoppingList, updateActions); updateCommand.Expand(r => r.Customer); var updatedShoppingList = await client.ExecuteAsync(updateCommand); Assert.NotNull(updatedShoppingList.Customer.Obj); Assert.Equal(customer.Key, updatedShoppingList.Customer.Obj.Key); return(updatedShoppingList); }); }); }