//
        // GET: /Admin/
        public ActionResult Index()
        {
            QuizRepository repo = new QuizRepository();

            int quizId = 1;
            int hoursToAggregateVotes = -12;

            var data = repo.GetVotes(quizId,DateTime.Now.AddHours(hoursToAggregateVotes));

            QuizResultViewModel results = new QuizResultViewModel();

            results.QuestionId = data.QuestionId;

            foreach (var option in data.Answers)
            {
                results.Options.Add(new Option
                                        {
                                            AnswerText = option.AnswerText,
                                            NumberOfVotes = option.NumberOfVotes,
                                            Id = option.Id
                                       });

            }

            CalculateVotingPercentages(results);

            return View(results);
        }
        public ActionResult Index(QuestionViewModel model)
        {
            //save result

            QuizRepository repo = new QuizRepository();

            DAL.QuizResponse response = new QuizResponse();
            response.AnswerId = model.SelectedAnswer;
            response.QuestionId = model.Id;
            repo.SaveAnswer(response);

            return RedirectToAction("Thanks");
        }
        //
        // GET: /Home/
        public ActionResult Index()
        {
            int quizId = 1;

            QuizRepository repo = new QuizRepository();
            var question = repo.GetQuestion(quizId);

            QuestionViewModel result = new QuestionViewModel();

            result.Id = question.Id;
            result.QuestionText = question.QuestionText;
            result.Answers = new List<Models.Answer>();

            foreach (var answer in question.Answers)
            {
                result.Answers.Add(new Models.Answer { AnswerText = answer.Answer1, Id = answer.AnswerId });
            }

            return View(result);
        }