Exemple #1
0
        public async Task <IList <QuestionDTO> > GetRandomQuestionsForCourse(int courseId)
        {
            // AutoMapper Setup.
            var iMapper = BLLAutoMapper.GetMapper;

            try
            {
                List <Question>    source             = Database.Question.Find(question => question.Topic.CourseId == courseId).ToList();
                List <QuestionDTO> allCourseQuestions = iMapper.Map <List <Question>, List <QuestionDTO> >(source);
                int questionCount = (await Database.Course.GetAsync(courseId)).CourseTestQuestionsNumber;
                return(BLLRepository.RandomQuestionList(allCourseQuestions, questionCount));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }