// GET: Articles public ActionResult Index(int?id, bool?partial, int?page, int?top) { IQueryable <Article> result = db.Articles.OrderByDescending(a => a.PublishDate); if (TCHelper.GetCurrentTCName() != "" && TCHelper.GetCurrentTCName() != "empty") { ViewBag.TrainingCenter = TCHelper.GetCurrentTc(db); result = result.Where(a => a.TrainingCenter.Id == this.trainingCenter.Id); } if (id != null) { ViewBag.Type = id; result = result.Where(a => a.Type == (Article.ArticleType)id); } //int pageSize = page == null ? Int32.MaxValue : (Int32)HttpContext.Application["PageSize"]; int pageSize = top != null ? (int)top : (Int32)HttpContext.Application["PageSize"]; int pageNumber = (page ?? 1); var pagedRes = result.ToPagedList(pageNumber, pageSize); if (partial != null && partial == true) { return(PartialView(pagedRes)); } return(View(pagedRes)); }
public ActionResult Index() { //db.TrainingCenters.Add(new TrainingCenter { Url = "empty" }); //db.SaveChanges(); ViewBag.TrainingCenter = TCHelper.GetCurrentTc(); return(View()); }