CHAPTER 7 ■ AZURE .NET SERVICES—WORKFLOWS 228 }, new NextItem { Relative = ShoppingCartItem.ENDPOINT ITEM UPDATE, Uri = string.Format("{0}{1}", WorkflowEnvironment.WorkflowInstanceId.ToString()) }, new NextItem { ShoppingCartItem.SHOPPING CART URI, Relative = ShoppingCartItem.ENDPOINT ITEM DELETE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING CART URI, WorkflowEnvironment.WorkflowInstanceId.ToString()) } }; WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Created; } private void codeUpdateShoppingCartItem ExecuteCode(object sender, EventArgs e) { var id = WorkflowEnvironment.WorkflowInstanceId.ToString(); currentShoppingCartItem.ShoppingCartItemId = receivedId; currentShoppingCartItem.ItemName = receivedShoppingCartItem.ItemName; currentShoppingCartItem.Price = receivedShoppingCartItem.Price; currentShoppingCartItem.NextItem = new NextItem[] { new NextItem { Relative = ShoppingCartItem.ENDPOINT CREDITCARD PAYMENT, Uri = string.Format("{0}{1}", ShoppingCartItem.CREDIT CARD PAYMENT URI, id.ToString()), }, new NextItem { Relative = ShoppingCartItem.ENDPOINT ITEM UPDATE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING CART URI, id.ToString()), }, new NextItem { Relative = ShoppingCartItem.ENDPOINT ITEM DELETE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING CART URI, id.ToString()), } }; CHAPTER 7 ■ AZURE .NET SERVICES—WORKFLOWS 229 WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK; } private void codePayShoppingCartItem ExecuteCode(object sender, EventArgs e) { var id = WorkflowEnvironment.WorkflowInstanceId.ToString(); currentShoppingCartItem.ShoppingCartItemId = receivedId; currentShoppingCartItem.ItemName = receivedShoppingCartItem.ItemName; currentShoppingCartItem.Price = receivedShoppingCartItem.Price; currentShoppingCartItem.NextItem = new NextItem[] { new NextItem { Relative = ShoppingCartItem.ENDPOINT CREDITCARD PAYMENT, Uri = string.Format("{0}{1}", ShoppingCartItem.CREDIT CARD PAYMENT URI, id.ToString()), }, new NextItem { Relative = ShoppingCartItem.ENDPOINT ITEM UPDATE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING CART URI, id.ToString()), }, new NextItem { Relative = ShoppingCartItem.ENDPOINT ITEM DELETE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING CART URI, id.ToString()), } }; WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Created; } private void codeCheckOutShoppingCartItem ExecuteCode(object sender, EventArgs e) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Created; } } } CHAPTER 7 ■ AZURE .NET SERVICES—WORKFLOWS 230 6. Now we need to bind the state machine workflow item properties to the corresponding handler. Figure 7-9 shows the bindings for WaitingForShoppingCartItem:eventItemAdded. Figure 7-9. Bindings for WaitingForShoppingCartItem:eventItemAdded CHAPTER 7 ■ AZURE .NET SERVICES—WORKFLOWS 231 7. The bindings for ShoppingCartItemPlaced:eventItemUpdated are shown in Figure 7-10. Figure 7-10. Bindings for ForShoppingCartItem:eventItemUpdated CHAPTER 7 ■ AZURE .NET SERVICES—WORKFLOWS 232 8. Bindings for ShoppingCartItemWorkflow:ShoppingCartItemPlaced are shown in Figure 7-11. Figure 7-11. Bindings for ShoppingCartItemWorkflow:ShoppingCartItemPlaced