public ActionResult Vote(byte voteId) { try { var poll = _pollsQuery.GetActivePoll(); if (poll != null) { if (voteId < poll.Answers.Count) { var userId = CurrentMember == null ? CurrentAnonymousUser.Id : CurrentMember.Id; _pollsCommand.CreatePollAnswerVote(new PollAnswerVote { AnswerId = poll.Answers[voteId].Id, UserId = userId }); } } return(PartialView("ActivePoll", new PollModel { Poll = poll, Votes = poll != null ? _pollsQuery.GetPollAnswerVotes(poll.Id) : null })); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(Json(new JsonResponseModel())); }
public ActionResult Resources() { // Gather all the pieces. var poll = _pollsQuery.GetActivePoll(); var featuredArticles = _resourcesQuery.GetFeaturedArticles(); var articles = _resourcesQuery.GetArticles(from a in featuredArticles select a.ResourceId); var featuredVideo = _resourcesQuery.GetFeaturedVideos().Single(); var video = _resourcesQuery.GetVideo(featuredVideo.ResourceId); var featuredQnA = _resourcesQuery.GetFeaturedQnAs().Single(); var qna = _resourcesQuery.GetQnA(featuredQnA.ResourceId); return(View(new ResourcesModel { Categories = _resourcesQuery.GetCategories(), FeaturedArticles = featuredArticles.Select(r => new FeaturedArticleModel { FeaturedResource = r, Article = articles.Single(a => a.Id == r.ResourceId) }).ToList(), FeaturedVideo = video, FeaturedQnA = qna, FeaturedQnAViews = qna != null ? _resourcesQuery.GetViewingCount(qna.Id) : 0, FeaturedQnAComments = qna != null ? _disqusQuery.GetCommentCount(qna.Id) ?? 0 : 0, ActivePoll = GetPollModel(poll), })); }
public void TestCreatePoll() { var poll0 = CreatePoll(0, 3, true); var poll1 = CreatePoll(1, 4, false); AssertPoll(poll0, _pollsQuery.GetPoll(poll0.Name)); AssertPoll(poll0, _pollsQuery.GetActivePoll()); AssertPoll(poll1, _pollsQuery.GetPoll(poll1.Name)); }