예제 #1
0
        /// <summary>
        /// Gets all quizes and display them.
        /// </summary>
        public async Task OnGetAsync()
        {
            List <DisplayQuizModel> quizModels        = new List <DisplayQuizModel>();
            QuizData             quizData             = new QuizData(_db);
            List <DataQuizModel> dataAccessQuizModels = await quizData.GetQuizs();

            foreach (DataQuizModel dataAccessQuizModel in dataAccessQuizModels)
            {
                quizModels.Add(new DisplayQuizModel
                {
                    Id       = dataAccessQuizModel.Id,
                    Duration = dataAccessQuizModel.Duration,
                    Quiz     = dataAccessQuizModel.Quiz,
                });
            }

            Quizs = quizModels;
        }
예제 #2
0
        /// <summary>
        /// Get all quizs.
        /// </summary>
        private async Task <List <DisplayQuizModel> > GetQuizs()
        {
            QuizData quizData = new QuizData(_db);
            List <DisplayQuizModel> quizModels     = new List <DisplayQuizModel>();
            List <DataQuizModel>    dataQuizModels = await quizData.GetQuizs();

            foreach (var dataQuizModel in dataQuizModels)
            {
                quizModels.Add(new DisplayQuizModel
                {
                    Id       = dataQuizModel.Id,
                    Duration = dataQuizModel.Duration,
                    Quiz     = dataQuizModel.Quiz,
                });
            }

            return(quizModels);
        }