示例#1
0
        // GET: Producto
        public ActionResult Index(int?ID)
        {
            ViewProduct vm = new ViewProduct();

            vm.cargarData();
            using (var db = new SparrowModel())
            {
                if (!ID.HasValue)
                {
                    vm.productos = db.Producto.ToList();
                }
                else
                {
                    vm.productos = db.Producto.
                                   Include(x => x.categoria).
                                   Where(x => x.categoria.ID == ID).ToList();
                }
            }
            return(View(vm));
        }