public ActionResult Index()
        {
            var dataContext = new SpecOverflowEntities();

            var questions = dataContext.Questions.OrderByDescending(q => q.Views);

            return View(questions);
        }
        public void GivenTheFollowingQuestionsRegistered(Table table)
        {
            SpecOverflowEntities entities = new SpecOverflowEntities();

            foreach (var question in table.CreateSet(CreateDefaultQuestion))
            {
                entities.Questions.Add(question);
            }

            entities.SaveChanges();
        }
        public ActionResult Ask(QuestionModel question)
        {
            if (!ModelState.IsValid)
                return View();

            var dataContext = new SpecOverflowEntities();

            var dbQuestion = new Question();
            dbQuestion.Title = question.Title;
            dbQuestion.Body = question.Body;
            dbQuestion.DateCreated = DateTime.Now;
            dbQuestion.Votes = 0;
            dbQuestion.Views = 0;

            dataContext.Questions.Add(dbQuestion);
            dataContext.SaveChanges();

            if (Request.IsAjaxRequest())
            {
                return PartialView("_QuestionPartial", dbQuestion);
            }

            return RedirectToAction("Index");
        }