public ActionResult SPMoiNhap(int?skip) { SanPhamModel sp = new SanPhamModel(); int skipnum = (skip ?? 0); IQueryable <SanPham> splist = sp.SPMoiNhap(); splist = splist.OrderBy(r => r.MaSP).Skip(skipnum).Take(4); if (splist.Any()) { return(PartialView("_ProductTabLoadMorePartial", splist)); } else { return(null); } }
//public ActionResult Sort(string jsonsort) //{ // dynamic item = JObject.Parse(jsonsort); // var term = jsonsort.prop1; // return AdvancedSearchP(null, null, null, null); //} public ActionResult AdvancedSearchP(string term, string loai, string hangsx, string typeview, int?page, int?minprice, int?maxprice, int?typepagelist, int?typesearch, int?typesort) { ViewBag.Name = term; ViewBag.loai = loai; ViewBag.hangsx = hangsx; ViewBag.minprice = minprice; ViewBag.maxprice = maxprice; ViewBag.type = typeview; ViewBag.typesearch = typesearch; ViewBag.typesort = typesort; ViewBag.page = page; ViewBag.typepagelist = typepagelist; // Phân loại search và sort SanPhamModel sp = new SanPhamModel(); IQueryable <SanPham> lst; int loaisearch = (typesearch ?? 0);// kiểu search là null thì sẽ là 0 if (loaisearch == 0) { lst = sp.AdvancedSearch(term, loai, hangsx, minprice, maxprice); if (typesort == 1) { lst = lst.OrderBy(e => e.GiaTien); } else if (typesort == 2) { lst = lst.OrderByDescending(e => e.GiaTien); } else { lst = lst.OrderByDescending(m => m.MaSP); } } else if (loaisearch == 1) { lst = sp.SPKhuyenMai(); if (typesort == 1) { lst = lst.OrderBy(e => e.GiaTien); } else if (typesort == 2) { lst = lst.OrderByDescending(e => e.GiaTien); } else { lst = lst.OrderByDescending(m => m.MaSP); } } else if (loaisearch == 2) { lst = sp.SPBanChay(0); if (typesort == 1) { lst = lst.OrderBy(e => e.GiaTien); } else if (typesort == 2) { lst = lst.OrderByDescending(e => e.GiaTien); } else { lst = lst.OrderByDescending(m => m.MaSP); } } else if (loaisearch == 3) { lst = sp.SPHot(); if (typesort == 1) { lst = lst.OrderBy(e => e.GiaTien); } else if (typesort == 2) { lst = lst.OrderByDescending(e => e.GiaTien); } else { lst = lst.OrderByDescending(m => m.MaSP); } } else if (loaisearch == 4) { lst = sp.SPMoiNhap(); if (typesort == 1) { lst = lst.OrderBy(e => e.GiaTien); } else if (typesort == 2) { lst = lst.OrderByDescending(e => e.GiaTien); } else { lst = lst.OrderByDescending(m => m.MaSP); } } else { lst = ManagerObiect.getIntance().Laydanhsachsanphammoixem().AsQueryable(); if (typesort == 1) { lst = lst.OrderBy(e => e.GiaTien); } else if (typesort == 2) { lst = lst.OrderByDescending(e => e.GiaTien); } else { lst = lst.OrderByDescending(m => m.MaSP); } } // xét phân trang int typePT = (typepagelist ?? 0); if (typePT == 1) { return(PhanTrangAdvanced2(lst, page)); } else { return(PhanTrangAdvanced(lst, page)); } }