public void WhenIAskANewQuestionWith(Question question) { #region alternatives for "reusing" steps //BrowserContext.Current.Browser.NavigateTo("/"); //new HomePageSteps().WhenIGoToTheHomePage(); //EnsureToBeOnHomePage(); //homePageDriver.NavigateTo(); #endregion When("I go to the home page"); BrowserContext.Current.Browser.SetTextBoxValue("Title", question.Title); BrowserContext.Current.Browser.SetTextBoxValue("Body", question.Body); BrowserContext.Current.Browser.SubmitForm(); }
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"); }