public async Task ShowPreviousSelectionFromCurrentQuestion(IDialogContext context, BOT_QUESTION currentQuestion) { if (currentQuestion.PREVQUESTION_ID != null) { //List<BOT_QUESTION> listPrevQuestion = DAO_QUESTION.BOT_QUESTION_GetByPrevQuestionId(currentQuestion.PREVQUESTION_ID.Value).ToList(); //await ShowListQuestion(context, listPrevQuestion); List <BOT_QUESTION> listPrevQuestions = DAO_QUESTION.BOT_QUESTION_GetPreviousSelectQuestions(currentQuestion.PREVQUESTION_ID.Value).ToList(); await ShowListQuestion(context, listPrevQuestions); } else { if (currentQuestion.LEVEL == 1) { List <BOT_QUESTION> listPrevQuestions = DAO_QUESTION.BOT_QUESTION_GetByLevel(currentQuestion.LEVEL.Value).ToList(); await ShowListQuestion(context, listPrevQuestions); } } if (currentQuestion.PREVANSWER_ID != null) { List <BOT_ANSWER> listPrevAnswers = DAO_ANSWER.BOT_ANSWER_GetByPreviousSelectAnswers(currentQuestion.PREVANSWER_ID.Value).ToList(); await ShowListAnswer(context, listPrevAnswers); // List<BOT_ANSWER> listPrevAnswer } }
public async Task ShowPreviousSelectionFromCurrentAnswer(IDialogContext context, BOT_ANSWER currentAnswer) { if (currentAnswer.QUESTION_ID != null && currentAnswer.QUESTION_ID != -1) { List <BOT_QUESTION> listPrevQuestions = DAO_QUESTION.BOT_QUESTION_GetPreviousSelectQuestions(currentAnswer.QUESTION_ID.Value).ToList(); if (listPrevQuestions.All(question => question.LEVEL != 1)) { BOT_QUESTION backQuestion = new BOT_QUESTION(); backQuestion.QUESTION_ID = -1; backQuestion.CONTENT = "<-Quay lại"; backQuestion.DOMAIN_ID = -1; backQuestion.FORM_ID = -1; backQuestion.IS_END = true; backQuestion.PREVANSWER_ID = -1; backQuestion.PREVQUESTION_ID = listPrevQuestions[0].PREVQUESTION_ID; backQuestion.QUESTION_TYPE = -1; backQuestion.RECORD_STATUS = -1; backQuestion.SCENARIO_ID = -1; backQuestion.LEVEL = -1; listPrevQuestions.Add(backQuestion); } await ShowListQuestion(context, listPrevQuestions); } if (currentAnswer.PREVANSWER_ID != null && currentAnswer.PREVANSWER_ID != -1) { List <BOT_ANSWER> listPrevAnswers = DAO_ANSWER.BOT_ANSWER_GetByPreviousSelectAnswers(currentAnswer.PREVANSWER_ID.Value).ToList(); BOT_ANSWER backAnswer = new BOT_ANSWER(); backAnswer.ANSWER_ID = -1; if (listPrevAnswers[0].QUESTION_ID != null) { backAnswer.QUESTION_ID = listPrevAnswers[0].QUESTION_ID; } else { backAnswer.QUESTION_ID = -1; } if (listPrevAnswers[0].PREVANSWER_ID != null) { backAnswer.PREVANSWER_ID = listPrevAnswers[0].PREVANSWER_ID; } else { backAnswer.PREVANSWER_ID = -1; } backAnswer.IS_END = true; backAnswer.LEVEL = -1; backAnswer.RECORD_STATUS = -1; backAnswer.CONTENT = "<-Quay lại"; backAnswer.RECORD_STATUS = -1; listPrevAnswers.Add(backAnswer); await ShowListAnswer(context, listPrevAnswers); } }