コード例 #1
0
        public Task Timeout(BuyersRemorseTimeout state, IMessageHandlerContext context)
        {
            context.Publish <IOrderPlaced>(
                o =>
            {
                o.OrderId    = Data.OrderId;
                o.TotalValue = Data.TotalValue;
            });

            MarkAsComplete();

            return(Task.CompletedTask);
        }
コード例 #2
0
        // ----------------------- Timeouts -----------------------
        public void Timeout(BuyersRemorseTimeout state)
        {
            // if the order is no longer around, it was cancelled
            if (!Data.Orders.Any(o => o.Id == state.OrderId))
            {
                return;
            }

            // complete the order
            Bus.Publish <OrderCompleted>(o =>
            {
                o.CustomerId   = state.CustomerId;
                o.OrderId      = state.OrderId;
                o.ProductId    = state.ProductId;
                o.Amount       = state.Amount;
                o.DateOccurred = DateTime.Now;
            });

            Console.WriteLine("------------------");
            Console.WriteLine("Order Completed: " + state.OrderId + " " + state.CustomerId + " " + state.ProductId + " " + state.Amount + " after " + (state.DiscountApplied * 100) + "% discount");
            PrintBalance();
            Console.WriteLine("------------------");
        }