コード例 #1
0
        // GET: Quizs/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var quiz = await _quizData.Items
                       .Include(q => q.Topic)
                       .FirstOrDefaultAsync(m => m.QuizID == id);

            if (quiz == null)
            {
                return(NotFound());
            }
            QuizViewModel QVM = new QuizViewModel
            {
                QuizID            = quiz.QuizID,
                NumberOfQuestions = quiz.NumberOfQuestions,
                TopicDescription  = quiz.Topic.Description,
                Score             = quiz.Score,
                Questions         = _quizData.QuizQuestions(quiz.QuizID).ToList()
            };

            return(View(QVM));
        }