public async Task <IActionResult> CreateQuiz()
        {
            try
            {
                IEnumerable <Difficulty> difficulties = null;
                difficulties = await quizRepo.GetAllDifficultiesAsync();

                ViewData["Difficulties"] = difficulties;
                return(View());
            }
            catch (Exception exc)
            {
                return(RedirectToAction(nameof(Quizzes), new { exc = exc.Message }));
            }
        }
示例#2
0
        public async Task <ActionResult <List <Difficulty_DTO> > > Get()
        {
            var model = await quizRepo.GetAllDifficultiesAsync();

            List <Difficulty_DTO> model_DTO = new List <Difficulty_DTO>();

            foreach (Difficulty difficulty in model)
            {
                var result = new Difficulty_DTO();
                model_DTO.Add(QuizMapper.ConvertDifficultyTo_DTO(difficulty, ref result));
            }
            return(Ok(model_DTO));
        }