public void Update(IMessage message)
        {
            Guid correlationId;

            Guid.TryParse(message.CorrelationId.ToString(), out correlationId);

            if (!string.IsNullOrWhiteSpace(message.DataAsString) &&
                message.DataAsString.ToLower() == "manualorder")
            {
                var orders = GetLastMonthsOrdersForRestaurantX(correlationId, _repo);

                if (orders != null)
                {
                    var stock = _stockQuantityControl.GetStockItems(orders);
                    Restaurant.SetStockQuantity(stock);
                    Console.WriteLine("Restaurant notified of stock shipped");
                }
            }
        }
Пример #2
0
        public void UpdateStock(IMessage message)
        {
            Guid correlationId;

            Guid.TryParse(message.CorrelationId.ToString(), out correlationId);
            var order = _repo.GetOrderByCorrelationId(message.CorrelationId);

            if (order != null)
            {
                var stock = _stockQuantityControl.GetStockItems(new List <Order> {
                    order
                });
                OrderMechanism.PlaceStockOrder(stock);

                // in reality this event would not be done here but raised when the suppliers ships the stock
                // it is here for the purposes of the demo and assuming that the stock IS shipped by the supplier
                _eventPublisher.RaiseEvent(order.CorrelationId, "ManualOrder", ConfigurationManager.AppSettings["StockOrders"]);
            }
        }