Beispiel #1
0
        public async Task <IActionResult> EditTest(int topicId, int testId)
        {
            List <QuestionModel> questions = (await _questionManager.GetQuestionsByTestIdSortedByStageAsync(testId))
                                             .Select(question =>
            {
                var questionModel = _mapper.Map <QuestionModel>(question);

                if (!string.IsNullOrWhiteSpace(question.ImageFullName))
                {
                    questionModel.ImageLocation = $"/{WebExtensions.ImagesFolderName}/" +
                                                  Path.GetFileName(questionModel.ImageFullName);
                }

                return(questionModel);
            })
                                             .ToList();

            DomainTest test = await _testManager.GetTestByIdAsync(testId);

            ViewData["TopicId"]  = topicId;
            ViewData["TestName"] = test.Name;
            ViewData["TestId"]   = test.Id;

            return(View(questions));
        }