// // GET: /Vote/ public ActionResult Index(int pollId = 1) { Poll poll = PollsDAL.GetPoll(pollId); if (poll == null) { return(Redirect("/Home/Index")); } ViewBag.Poll = poll; TimeSpan timeToNextVote = VotesDAL.TimeToNextVote(Request.ServerVariables["REMOTE_ADDR"], pollId); ViewBag.CanUserVote = timeToNextVote.TotalSeconds == 0; ViewBag.TimeToNextVote = string.Format("{0}:{1}:{2}", timeToNextVote.Hours, timeToNextVote.Minutes, timeToNextVote.Seconds); StringBuilder keywords = PossibleAnswersDAL.GetKeywords(pollId, poll); ViewBag.Keywords = keywords.ToString(); return(View()); }
// // GET: /Home/ public ActionResult Index(int pageNumber = 1) { Session["pageNumber"] = pageNumber; int pollsCount = PollsDAL.GetPollsCount(); int pollsPerPage = 3; int pagesCount = (int)Math.Ceiling((double)pollsCount / pollsPerPage); ViewBag.PagesCount = pagesCount; ViewBag.PollsCount = pollsCount; ViewBag.CurrentPageNumber = pageNumber; var polls = PollsDAL.GetPolls(pageNumber, pollsPerPage); ViewBag.Polls = polls; StringBuilder keywords = PollsDAL.ExtractKeywords(polls); ViewBag.Keywords = keywords.ToString(); return(View()); }