public ActionResult Create(CreateQuestionInputModel inputModel) { if (inputModel != null && this.ModelState.IsValid) { this.ValidateAnswers(inputModel.Answers); if (this.ModelState.IsValid) { var context = new VotingSystemEntities(); var newQuestion = new Question { Content = inputModel.Content, RequireNames = inputModel.RequireNames }; this.AddQuestionAnswers(inputModel.Answers, newQuestion); this.GenerateQuestionUrlId(newQuestion); context.Questions.Add(newQuestion); context.SaveChanges(); return Redirect("/Vote/Index/" + newQuestion.UrlId); } } return this.View("~/Views/Home/Index.cshtml", inputModel ?? new CreateQuestionInputModel()); }
public IndexModel() { VotingSystemEntities db = new VotingSystemEntities(); this.User_Recording = db.User_Recording.ToList(); this.Topic_Recording = db.Topic_Recording.ToList(); }