public ActionResult IndexX() { string category = "Gambia"; ViewBag.Category = category; int category_id = AppFunctions.GetCategoryIDFromText(category); var data = db.NewsArticles.Where(s => s.ArticleCategory == category_id && s.ReviewStatus == 1 && s.DeleteStatus == false).OrderByDescending(s => s.ID); ViewBag.total_records = db.NewsArticles.Count(s => s.ArticleCategory == category_id && s.DeleteStatus == false); return(View(data)); }
// GET: Health public ActionResult Index(int page = 0) { string category = "Health"; ViewBag.Category = category; int category_id = AppFunctions.GetCategoryIDFromText(category); var dataSource = db.NewsArticles.Where(s => s.ArticleCategory == category_id && s.ReviewStatus == 1 && s.DeleteStatus == false).OrderByDescending(s => s.ID); const int PageSize = 6; // you can always do something more elegant to set this var count = dataSource.Count(); var data = dataSource.Skip(page * PageSize).Take(PageSize).ToList(); ViewBag.MaxPage = (count / PageSize) - (count % PageSize == 0 ? 1 : 0); ViewBag.Page = page; return(View(data)); }