public ActionResult Result(SubmittedQuizViewModel quiz)
        {
            if (ModelState.IsValid)
            {
                Quiz passedQuiz = quizService.GetById(quiz.Id);

                QuizResultViewModel result = new QuizResultViewModel()
                { Title = passedQuiz.Title, Questions = new List<QuizQuestionResultViewModel>() };

                result.Total = quiz.Answers.Count;

                for (int i = 0; i < quiz.Answers.Count; i++)
                {
                    QuizQuestion testQuestion = passedQuiz.Questions.ElementAt(i);

                    QuizQuestionResultViewModel questionResult = new QuizQuestionResultViewModel()
                    {
                        Text = testQuestion.Text,
                        Answers = testQuestion.AnswerOptions.ToList(),
                        Correct = testQuestion.CorrectAnswer,
                        Selected = quiz.Answers[i]
                    };

                    if (questionResult.Selected == testQuestion.CorrectAnswer)
                    {
                        result.Correct++;
                    }

                    result.Questions.Add(questionResult);

                }

                User user = userService.GetByEmail(User.Identity.Name);

                if (user != null)
                {
                    QuizStatistic statistic = new QuizStatistic()
                    { DatePassed = DateTime.Now, QuizId = passedQuiz.Id, Correct = result.Correct, UserId = user.Id };
                    statisticService.Create(statistic);
                }

                return View(result);
            }

            return RedirectToAction("Index");
        }
 public void Create(QuizStatistic statistic)
 {
     uow.StatisticRepository.Create(statistic.ToDalStatistic());
     uow.SaveChanges();
 }