public ActionResult Index(OrderDetails orderDetails) { var placeOrderCommand = new PlaceOrder(new List<string>{orderDetails.Item1, orderDetails.Item2}, orderDetails.Price, orderDetails.CustomerName); // Publish the PlaceOrder command here. return View("Placed", placeOrderCommand); }
public override bool Handle(PlaceOrder message) { _i ++; if (_i%2 == 0) // Process 50% of order requests successfully { Console.WriteLine("OOPS, DB error processing order for {0}", message.CustomerName); throw new Exception("DB BLEW UP!"); } return base.Handle(message); }
// Order processing method. Needs to be called with a PlaceOrder message from the JustSaying bus. private bool PlaceAnOrder(PlaceOrder message) { Console.WriteLine("I've been asked to place an order for '{0}' costing '{1}'", message.CustomerName, message.Price); Console.WriteLine("Saving to DB order for '{0}'", message.CustomerName); Thread.Sleep(50); // pretend to do some work Console.WriteLine("Validating order for '{0}' against some rules", message.CustomerName); Thread.Sleep(100); // pretend to do some work // Order Validated. Console.WriteLine("VALIDATED OK: order for '{0}'", message.CustomerName); return true; }