예제 #1
0
        public void Handle(CookFood message)
        {
            var order = message.Order;

            _horn.Say($"[cook] {_cookName}: cooking order {order.OrderId}.");
            Thread.Sleep(_processingTime);
            order.Ingredients = "some stuff";
            _horn.Say($"[cook] {_cookName}: cooked order {order.OrderId}.");

            _publisher.Publish(new OrderCooked(message, new Order(order)));
        }
예제 #2
0
        public void Handle(TakePayment message)
        {
            var order = message.Order;

            _horn.Say($"[cashier]: taking payment for {order.OrderId}.");

            Thread.Sleep(500);

            order.IsPaid = true;

            _horn.Say($"[cashier]: took payment for {order.OrderId}.");

            _publisher.Publish(new OrderPaid(message, new Order(order)));
        }
        public void PlaceNewOrder(Guid orderId, IDictionary <string, int> itemQuantitySpec)
        {
            var order = new Order
            {
                OrderId   = orderId.ToString("N"),
                LineItems = itemQuantitySpec.Select(pair => new LineItemDto {
                    Item = pair.Key, Quantity = pair.Value
                }).ToList()
            };

            _horn.Say($"[waiter]: placing new order {order.OrderId}.");

            var isDodgyCustomer = itemQuantitySpec.Any(x => x.Key == GoodsMenu.Drinkables.Vodka);

            _publisher.Publish(new OrderPlaced(isDodgyCustomer, new Order(order)));
            _horn.Say($"[waiter]: placed new order {order.OrderId}.");
        }
        public void Handle(PriceOrder message)
        {
            var order = message.Order;

            _horn.Say($"[asstManager]: calculating prices for {order.OrderId}.");

            Thread.Sleep(250);
            var random = new Random();

            order.LineItems = order.LineItems.Select(x => new LineItemDto
            {
                Item     = x.Item,
                Price    = random.Next(1000),
                Quantity = x.Quantity
            }).ToList();
            var totalPerItems = order.LineItems.Select(x => x.Price).Sum();
            var tax           = (int)Math.Round(0.2 * totalPerItems);

            order.Tax    = tax;
            order.Totals = tax + totalPerItems;

            _publisher.Publish(new OrderPriced(message, new Order(order)));
        }
 public void Handle(PrintReceipt message)
 {
     _horn.Say("[printer]: printing");
     Thread.Sleep(750);
     _horn.Say("[printer]: " + message.Order.MutableContainer);
 }