Exemple #1
0
        public ActionResult GetListProduct(decimal?PriceMin, decimal?PriceMax, int?CatID, int?ProducerID, int page = 1)
        {
            ViewBag.PriceMin   = PriceMin;
            ViewBag.PriceMax   = PriceMax;
            ViewBag.CatID      = CatID;
            ViewBag.ProducerID = ProducerID;

            var List        = CSDLQLBH.GetProducts();
            var ListProduct = List.ToList();


            if (PriceMin != null)
            {
                ListProduct = List.Where(p => p.Price > PriceMin).ToList();
            }

            if (PriceMax != null)
            {
                ListProduct = ListProduct.Where(p => p.Price < PriceMax).ToList();
            }

            if (CatID != null)
            {
                ListProduct = ListProduct.Where(p => p.CatID == CatID).ToList();
            }

            if (ProducerID != null)
            {
                ListProduct = ListProduct.Where(p => p.ProducerID == ProducerID).ToList();
            }


            int totalP = ListProduct.Count();
            int nPage  = totalP / nPerPage + (totalP % nPerPage > 0 ? 1 : 0);

            if (page < 1)
            {
                page = 1;
            }
            if (page > nPage)
            {
                page = nPage;
            }

            ViewBag.totalPage = nPage;
            ViewBag.curPage   = page;
            ListProduct       = ListProduct.OrderBy(p => p.ProID)
                                .Skip((page - 1) * nPerPage)
                                .Take(nPerPage)
                                .ToList();

            return(View("SearchNangCao", ListProduct));
        }
Exemple #2
0
        // GET: Home
        public ActionResult Index()
        {
            var l = CSDLQLBH.GetProducts().ToList();

            return(View(l));
        }
        //sản phẩm cùng nhà sản xuất
        public ActionResult ProductAsProducer(int producerID, int proID)
        {
            var l = CSDLQLBH.GetProducts(filter: "ProducerID = " + producerID + " and ProID != " + proID).Take(5).ToList();

            return(PartialView("ProductAsProducer", l));
        }
        //sản phẩm cùng loại
        public ActionResult ProductTheSame(int catID, int proID)
        {
            var l = CSDLQLBH.GetProducts(filter: "CatID = " + catID + " and ProID != " + proID).Take(6).ToList();

            return(PartialView("ProductTheSame", l));
        }