Example #1
0
        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);
        }
Example #2
0
        public ActionResult Delete(int id, Question deleteQuestion, IFormCollection collection)
        {
            try
            {
                _questionRepo.DeleteQuestion(id);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to delete a question: {ex}");
                return(View());
            }
        }
Example #3
0
        public IActionResult DeleteQuiz(uint id)
        {
            List <Question> questions = new List <Question>();

            questions = _question.GetQuestionsWithQuizId(id);

            for (int i = 0; i < questions.Count; i++)
            {
                _question.DeleteQuestion(questions[i].IdQuestion);
            }

            _quiz.DeteleQuiz(id);

            return(RedirectToAction("MyProfile"));
        }
Example #4
0
 public IHttpActionResult DELETE(int id)
 {
     _adapter.DeleteQuestion(id);
     return(Ok());
 }
Example #5
0
 public static void DeleteQuestion(int Id)
 {
     dal.DeleteQuestion(Id.ToString());
 }