public ActionResult Index(string search, string type) { IserviceProduct ip = new serviceProduct(); string ch = search; //valeur à chercher string ch1 = type; //type de trie List <Product> lp = ip.search_kw(search).Where(a => a.qteprod > 0).ToList(); if (type.Equals("desc")) { lp.Reverse(); } return(View(lp)); }
public ActionResult Index(string search, string type, string btPage) {//this method maymeshaa haad w manajemch nfasarha li yheb yefhemha nfahemhelou ki net9ablou IserviceProduct ip = new serviceProduct(); List <Product> lp = new List <Product>(); if (type != null) { string ch = search; //valeur à chercher string ch1 = type; //type de trie lp = ip.search_kw(search).Where(a => a.qteprod > 0).ToList(); if (!type.Equals("desc")) { lp.Reverse(); order = true; } else { order = false; } } else { int page = Int32.Parse(btPage); lp = ip.listprod(); if (order) { lp.Reverse(); lp = lp.Skip((page - 1) * 12).ToList(); } else { lp = lp.Skip((page - 1) * 12).ToList(); } } ViewBag.pagenb = ip.listprod().Count / 12; return(View(lp)); }