public RichQuestion(Question question, int votes, VoteType? currentUsersVotes, List<RichAnswer> answers, int answerCount)
 {
     Question = question;
     Votes = votes;
     CurrentUsersVote = currentUsersVotes;
     Answers = answers;
     AnswerCount = answerCount;
 }
 public ActionResult Ask(string title, string body)
 {
     if (GetCurrentUser() == null)
         return RedirectToLoginPage();
     var now = DateTime.Now;
     var question = new Question
         {
             CreatedDate = now,
             Author = GetCurrentUser(),
             Body = body,
             LastRelatedUser = GetCurrentUser(),
             Title = title,
             UpdateDate = now,
         };
     _questionsRepository.Save(question);
     return RedirectToAction("Details", new {id = question.Id});
 }
 private void AddQuestion()
 {
     var author = _users.Random(_random);
     int bodyLength = _random.Next(15) + 5;
     string body = RandomText(bodyLength);
     var creationDate = GetRandomDate();
     var question = new Question
                        {
                            Author = author,
                            Title = "Random question about " + RandomWord() + "?",
                            Body = body + "?",
                            UpdateDate = creationDate,
                            CreatedDate = creationDate,
                        };
     _questions.Add(question);
     _questionsRepository.Save(question);
 }
 public void SavingQuestionWithDefaultDate_Fails()
 {
     var user = new User {Name = "Foob"};
     _userRepository.Save(user);
     var question = new Question{Author = user, Body = "Asdf", Title = "ASd"};
     _questionsRepository.Save(question);
 }
 public void SaveProblem()
 {
     var u = new User { SignupDate = DateTime.Now, Name = "Foo", OpenId = "Bar" };
     ActiveRecordMediator<User>.Save(u);
     var q = new Question
     {
         Author = u,
         Body = "",
         CreatedDate = DateTime.Now,
         LastRelatedUser = u,
         Title = "",
         UpdateDate = DateTime.Now
     };
     ActiveRecordMediator<Question>.Save(q);
     var v = new VoteOnQuestion { Key = new VoteKey(u.Id, q.Id) };
     ActiveRecordMediator<VoteOnQuestion>.Save(v);
 }
 private void AssertVotesOnQuestion(int exectedVotes, Question question)
 {
     question = QuestionsRepository.GetById(question.Id);
     Assert.AreEqual(exectedVotes, question.Votes);
 }
        private void CreateData()
        {
            _questionAuthor = UserFactory.CreateUser();
            _question = SaveQuestion(_questionAuthor);
            for (int i = 0; i < 5; ++i)
            {
                var answer = new Answer
                {
                    Author = _questionAuthor,
                    Body = i.ToString(),
                    CreatedDate = DateTime.Now,
                    LastRelatedUser = _questionAuthor,
                    QuestionId = _question.Id,
                    UpdateDate = DateTime.Now
                };
                _answersRepository.Save(answer);
                _answers.Add(answer);

                // add i up-votes for answer i
                for (int j = 0; j < i; ++j)
                {
                    var voter = UserFactory.CreateUser();
                    AnswerVoteRepository.CreateOrUpdateVote(voter, answer, VoteType.ThumbUp);
                }
            }
        }