Пример #1
0
        public ICollection <PPinfoCase> GetProducts()
        {
            ICollection <PPinfoCase> viewModel = new List <PPinfoCase>();
            PPinfoCase temp;

            //get products and ProdInfo
            var products = from Product in db.Products
                           select Product;
            var prodinfo = from ProdInfo in db.ProductInfo
                           select ProdInfo;

            foreach (Product p in products)
            {
                temp = new PPinfoCase();
                temp.getItems(p, prodinfo.ToList());
                viewModel.Add(temp);
            }

            if (ModelState.IsValid)
            {
                ModelState.Clear();
            }

            return(viewModel);
        }
Пример #2
0
        // GET: Products
        public ActionResult Index(string search, string quantity)
        {
            //public List<PPinfoCase> itemList;
            ICollection <PPinfoCase> viewModel = new List <PPinfoCase>();
            PPinfoCase temp;

            //get products and ProdInfo
            var products = from Product in db.Products
                           select Product;
            var prodinfo = from ProdInfo in db.ProductInfo
                           select ProdInfo;

            foreach (Product prod in products)
            {
                temp = new PPinfoCase();
                temp.getItems(prod, prodinfo.ToList());
                viewModel.Add(temp);
            }

            if (!string.IsNullOrEmpty(search))
            {
                return(View(viewModel.Where(d => (d.Product.ProductName.ToLower().Contains(search.ToLower())) ||
                                            (d.Product.Description.ToLower().Contains(search.ToLower())))
                            .ToList()));
            }

            return(View(viewModel.ToList()));

            //return View(db.Products.ToList());
        }