public ActionResult GetByKeywords(string search, int page = 1) { try { if (search == null) { return(RedirectToAction("Index", "Home")); } var sonuc = new Repository.ArticleRepo() .Queryable() .Where(x => x.Header.Contains(search) || x.User.UserName.Contains(search) || x.User.Surname.Contains(search) || x.Content.Contains(search) || x.Category.CategoryName.Contains(search)).ToList(); ViewBag.count = sonuc.Count(); var model = sonuc.Skip((page - 1) * 5).Take(5).ToList(); if (model.Count == 0) { return(RedirectToAction("Index", "Home")); } return(View(model)); } catch (Exception ex) { return(RedirectToAction("Index", "Home")); } }
public ActionResult GetByCatId(int id, int page = 1) { var sonuc = new Repository.ArticleRepo().Queryable().Where(x => x.CategoryId == id).ToList(); ViewBag.Count = sonuc.Count; var model = sonuc.Skip((page - 1) * 5).Take(5).ToList(); return(View(model)); }