コード例 #1
0
        public async Task <IActionResult> DeleteAnswer(Guid id, IFormCollection collection, Guid QuizId, Guid QuestionId)
        {
            try
            {
                await quizRepo.DeleteAnswer(id);

                Question question = await quizRepo.GetQuestionForIdAsync(QuestionId);

                if (question == null || QuestionId == Guid.Empty)
                {
                    return(RedirectToAction(nameof(Quizzes), new { exc = "Wrong QuestionId" }));
                }
                return(RedirectToAction(nameof(QuestionAnswers), new { id = QuestionId, QuizId = QuizId, QuestionName = question.Description }));
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                return(View());
            }
        }