public async Task <IActionResult> EditTitle(QuestionnaireClass editQuestionnaire) { if (ModelState.IsValid) { _db.Update(editQuestionnaire); await _db.SaveChangesAsync(); return(RedirectToAction("Index", "Questions", new { id = editQuestionnaire.id })); } return(View(editQuestionnaire)); }
public async Task <IActionResult> Edit(QuestionClass editQuestion) { if (ModelState.IsValid) { var x = editQuestion.questionnaire_id; _db.Update(editQuestion); var resetAnswers = _db.Answers.Where(x => x.questionnaire_Id == editQuestion.questionnaire_id).ToList(); foreach (var rm in resetAnswers) { _db.Answers.Remove(rm); } await _db.SaveChangesAsync(); return(RedirectToAction("Index", new { id = editQuestion.questionnaire_id })); } return(View(editQuestion)); }