Exemple #1
0
        public ActionResult Delete(int id, SurveyModel survey)
        {
            int i = 0;

            survey          = gSurvey.Obter(id);
            survey.questoes = gQuestao.ListaQuestaoSurvey(id).ToList();
            if (ModelState.IsValid)
            {
                foreach (QuestaoModel questao in survey.questoes)
                {
                    gResposta.RemoverRespostaPorQuestao(questao.id_Questao);
                    survey.questoes[i].itens   = gItens.ObterItens(survey.questoes[i].id_Questao).ToList();
                    survey.questoes[i].codigos = gClasses.ObterClasses(survey.questoes[i].id_Questao).ToList();
                    foreach (Itens_da_QuestaoModel item in survey.questoes[i].itens)
                    {
                        gItens.RemoverPorQuestao(questao.id_Questao);
                    }
                    foreach (ClasseModel item in survey.questoes[i].codigos)
                    {
                        gClasses.RemoverPorQuestao(questao.id_Questao);
                    }


                    i++;
                }
                foreach (QuestaoModel questao in survey.questoes)
                {
                    gQuestao.RemoverQuestaoPorSurvey(id);
                }
            }
            gSurvey.Remover(id);
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public ActionResult Delete(int id, QuestaoModel questaoModel)
        {
            questaoModel = gQuestao.Obter(id);
            if (ModelState.IsValid)
            {
                List <Itens_da_QuestaoModel> ListaItens   = gItens.ObterItens(questaoModel.id_Questao).ToList();
                List <ClasseModel>           ListaClasses = gClasses.ObterClasses(questaoModel.id_Questao).ToList();
                foreach (Itens_da_QuestaoModel itens in ListaItens)
                {
                    gItens.RemoverPorQuestao(itens.id_Questao);
                }
                foreach (ClasseModel itens in ListaClasses)
                {
                    gClasses.RemoverPorQuestao(itens.id_Questao);
                }
                gQuestao.Remover(id);
                return(RedirectToAction("ListaQuestoes/" + questaoModel.id_Survey, "Questao"));
            }

            return(View(questaoModel));
        }