Ejemplo n.º 1
0
        public ActionResult ViewOrder(int id)
        {
            using (var context = new RealGadgetContext())
            {
                var order = context.Orders.Find(id);

                var gadgetOrders = context.GadgetOrders.Where(go => go.OrderID == id);

                foreach (GadgetOrder gadgetOrder in gadgetOrders)
                {
                    context.Entry(gadgetOrder).Reference(go => go.Gadget).Load();
                    order.Gadgets.Add(gadgetOrder.Gadget);
                }

                return(View(order));
            }
        }