public async Task Delete(Guid id)
        {
            try
            {
                List <Answers> list = await answersRepo.GetAnswersByQuestion(id);

                foreach (Answers item in list)
                {
                    var deleteAnswers = context.Answers.Remove(item);
                    await context.SaveChangesAsync();
                }
                Questions question = await context.Questions.FindAsync(id);

                var result = context.Questions.Remove(question); //beter is hier te archiveren

                await context.SaveChangesAsync();
            }
            //return result.Entity.Id

            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
            }
            return;
        }
示例#2
0
        // GET: QuestionsAnswers
        public async Task <ActionResult> IndexAsync(Guid id)
        {
            ViewBag.QuizId = id;
            QuestionsAnswers model = new QuestionsAnswers();

            model.Questions = await questionsRepo.GetQuestionsByQuiz(id);

            List <Answers> list = new List <Answers>();

            foreach (Questions question in model.Questions)
            {
                foreach (var item in await answersRepo.GetAnswersByQuestion(question.QuestionID))
                {
                    list.Add(item);
                }
            }
            model.Answers = list;
            return(View(model));
        }