public ActionResult Index(int? clove, string searchstring, string sortOrder, string currentFilter, int? page, int? article_id) { if (!Request.IsAuthenticated) UserInformation.User = null; var list = new List<HomePageModel>(); var model = new HomePageModel(); model.CloveID = clove; // paging if (searchstring != null) page = 1; else searchstring = currentFilter; model.PageNumber = page ?? 1; ViewBag.CurrentFilter = searchstring; // search model.CloveSearch = searchstring; // sorting ViewBag.TitleSort = String.IsNullOrEmpty(sortOrder) ? "title_asc" : ""; ViewBag.AuthorSort = String.IsNullOrEmpty(sortOrder) ? "author_asc" : ""; ViewBag.VoteSort = String.IsNullOrEmpty(sortOrder) ? "votes_desc" : ""; model.CloveSort = sortOrder; // votes if (article_id != null) { v_votes vote = new v_votes { v_p_post = article_id ?? default(int), v_upvote = true, v_date = DateTime.Now }; db.v_votes.Add(vote); db.SaveChanges(); } list.Add(model); ViewBag.clove = new SelectList(model.Cloves, "c_id", "c_name"); return View(list); }
public PartialViewResult Vote(int article_id) { v_votes vote = new v_votes { v_p_post = article_id, v_upvote = true, v_date = DateTime.Now }; db.v_votes.Add(vote); db.SaveChanges(); return PartialView("_VotePartial", (from v in db.v_votes where v.v_p_post.Equals(article_id) select v).Count()); }