public IActionResult QuestionsSetting(SelectQuestions questions, AnswerQuestion answer) { ViewBag.name = HttpContext.Session.GetString("name"); ViewBag.img = HttpContext.Session.GetString("img"); string search = Request.Form["Search_info"]; if (search != null) { var info = userContent.SelectQuestions.Where(b => b.Que_name.Contains(search)).ToList(); ViewBag.questions = info; return(View()); } if (answer.AQ_Name != null) { userContent.AnswerQuestion.Add(answer); userContent.SaveChanges(); } else if (questions.Que_name != null) { userContent.SelectQuestions.Add(questions); userContent.SaveChanges(); } // var a = Request.Form["first"]; List <SelectQuestions> questions1 = userContent.SelectQuestions.ToList(); List <AnswerQuestion> answers = userContent.AnswerQuestion.ToList(); ViewBag.questions = questions1; ViewBag.answers = answers; return(View()); }
public int CreateSelect(SelectQuestions questions) { userContent.SelectQuestions.Add(questions); userContent.SaveChanges(); var id = userContent.SelectQuestions.FirstOrDefault(b => b.Que_name == questions.Que_name).Que_ID; return(id); }