Exemplo n.º 1
0
        public virtual ActionResult AnswerPoll(PollUserAnswerInput answer)
        {
            this.forumStorageWriter.SavePollAnswer(answer, this.User.Identity.Name);

            TopicPageRoutedata topicPage = this.forumStorageReader.GetRouteDataForLastTopicPage(answer.TopicId);

            return(this.RedirectToPost(topicPage));
        }
Exemplo n.º 2
0
        public void SavePollAnswer(PollUserAnswerInput userAnswer, string username)
        {
            Topic topic = this.ravenSession.Load <Topic>(userAnswer.TopicId);

            foreach (PollAnswer answer in topic.Poll.Answers)
            {
                // todo: Check whether this should be moved to the model
                bool newAnswerValue = userAnswer.CheckedAnswers.Contains(answer.Id);

                if (newAnswerValue && !answer.Usernames.Contains(username))
                {
                    answer.Usernames.Add(username);
                }
                else if (!newAnswerValue && answer.Usernames.Contains(username))
                {
                    answer.Usernames.Remove(username);
                }
            }
        }