// // GET: /TestPager/ public ActionResult Index(string title, string author, string source, int id = 1) { var qry = AllArticles.AsQueryable(); if (!string.IsNullOrWhiteSpace(title)) { qry = qry.Where(a => a.Title.Contains(title)); } if (!string.IsNullOrWhiteSpace(author)) { qry = qry.Where(a => a.Author.Contains(author)); } if (!string.IsNullOrWhiteSpace(source)) { qry = qry.Where(a => a.Source.Contains(source)); } var model = qry.OrderByDescending(a => a.PubDate).ToPagedList(id, 5); if (Request.IsAjaxRequest()) { return(PartialView("ArticleListPartial", model)); } return(View(model)); }
public ActionResult Search(int id = 1, string kword = null) { var query = AllArticles.AsQueryable(); if (!string.IsNullOrWhiteSpace(kword)) { query = query.Where(a => a.Title.Contains(kword)); } var model = query.OrderByDescending(a => a.PubDate).ToPagedList(id, 5); return(View(model)); }