public static OrderItem ConvertOrderToViewModel(PizzaOrder order)
        {
            // get the ingredients from the database
            var dataContext = new EnterprisePizzaDataContext();
            var ingredients = dataContext.AvailableIngredients.ToList();

            // build the object we'll throw into the service bus topic
            var item = new OrderItem
            {
                OrderId = order.Id,
                ClientIdentifier = order.ClientIdentifier.Value
            };

            // add the pizzas to the order
            order.Pizzas.ForEach(p =>
            {
                var pizzaItem = new PizzaItem
                {
                    PizzaId = p.Id
                };

                // add the sections to the pizza
                p.Sections.ForEach(s =>
                {
                    var sectionItem = new SectionItem();

                    s.Ingredients.ForEach(i =>
                    {
                        sectionItem.Toppings.Add(
                            ingredients.First(x =>
                                x.Id == i.AvailableIngredientId).Name);
                    });

                    pizzaItem.Sections.Add(sectionItem);
                });

                item.Pizzas.Add(pizzaItem);
            });

            return item;
        }
        public static OrderItem ConvertOrderToViewModel(PizzaOrder order, 
            IEnumerable<IngredientAvailability> ingredients)
        {
            // build the object we'll throw into the service bus topic
            var item = new OrderItem
            {
                OrderId = order.Id,
                ClientIdentifier = order.ClientIdentifier.Value
            };

            // add the pizzas to the order
            order.Pizzas.ForEach(p =>
            {
                var pizzaItem = new PizzaItem
                {
                    PizzaId = p.Id
                };

                // add the sections to the pizza
                p.Sections.ForEach(s =>
                {
                    var sectionItem = new SectionItem();

                    s.Ingredients.ForEach(i =>
                    {
                        sectionItem.Toppings.Add(
                            ingredients.First(x =>
                                x.Id == i.AvailableIngredientId).Name);
                    });

                    pizzaItem.Sections.Add(sectionItem);
                });

                item.Pizzas.Add(pizzaItem);
            });

            return item;
        }
 private void SendOrderStatus(OrderItem order, string status)
 {
     _orderStatusService.SendOrderStatus(new OrderStatusRequest
     {
         ClientIdentifier = order.ClientIdentifier,
         OrderId = order.OrderId,
         Status = status
     });
 }