public void DeleteSurvey(string surveyCode) { surveys survey = surveyDAL.GetSurveyBySurveyCode(surveyCode); List <questions> questions = questionDAL.GetQuestionsBySurveyId(survey.Id).ToList(); foreach (var question in questions) { if (inputTypeDAL.GetInputTypeName(question) == "text") { List <text_answers> texts = textAswersDAL.GetTextAnswers(question); foreach (var text in texts) { textAswersDAL.DeleteTextAnswer(text); } questionDAL.DeleteQuestion(question); } else { List <option_choices> options = optionChoiceDAL.GetOptionsChoices(question); foreach (var option in options) { List <answers> answers = answerDAL.GetAnswers(option.Id); foreach (var answer in answers) { answerDAL.DeleteAnswer(answer); } optionChoiceDAL.DeleteOptionChoice(option); } questionDAL.DeleteQuestion(question); } } surveyDAL.DeleteSurvey(survey); }
public JsonResult DeleteServey(long Id) { _survey.DeleteSurvey(Id); return(Json(new { status = "success", })); }