// // GET: Thread/Index/5 /// <summary> /// Returns the view that contains the list of threads /// associated with the forum with the given id. /// </summary> /// <param name="id">The id of the forum</param> /// <returns>View of the list of threads.</returns> public ActionResult Index(int id, int? page) { pageNumber = page ?? 1; pageNumber = (pageNumber < 1) ? 1 : pageNumber; Forum forum = db.Forums.SingleOrDefault(f => f.ForumId == id); List<Thread> threads = GetNonStickyThreads(forum); List<Thread> stickyThreads = (from t in forum.Threads where t.IsSticky == true select t).ToList(); ThreadListViewModel theModel = new ThreadListViewModel { Forum = forum, Threads = threads, StickyThreads = stickyThreads, PageNumber = pageNumber }; return View(theModel); }
public ActionResult ToggleSticky(int id) { Thread theThread = db.Threads.Single(t => t.ThreadId == id); theThread.IsSticky = !theThread.IsSticky; db.SaveChanges(); Forum forum = theThread.ContainingForum; List<Thread> threads = GetNonStickyThreads(forum); List<Thread> stickyThreads = (from t in forum.Threads where t.IsSticky == true select t).ToList(); ThreadListViewModel theModel = new ThreadListViewModel { StickyThreads = stickyThreads, Forum = forum, Threads = threads, PageNumber = this.pageNumber }; return PartialView("ThreadView", theModel); }