Exemplo n.º 1
0
        public UserAnswer Create(UserAnswer userAnswer)
        {
            using (var client = Server.OpenClient())
            {
                userAnswer.AnsweredBy = client.Query<User>(u => u.Id == userAnswer.AnsweredBy.Id).SingleOrDefault();
                userAnswer.Question = client.Query<Question>(q => q.Id == userAnswer.Question.Id).SingleOrDefault();
                userAnswer.Id = userAnswer.GetHashCode();

                client.Store(userAnswer);
            }

            return userAnswer;
        }
Exemplo n.º 2
0
        public void SaveUserAnswers(IDictionary<int, int> answers, User loggedUser)
        {
            foreach (var answer in answers)
            {
                var userAnswer = new UserAnswer()
                {
                    AnsweredBy = loggedUser,
                    AnsweredOn = DateTime.Now,
                    Question = questionRepository.Get(answer.Key),
                    Value = answer.Value
                };

                userAnswerRepository.Create(userAnswer);
            }
        }