Ejemplo n.º 1
0
        public static Result_DTO ConvertResultTo_DTO(Result result, ref Result_DTO result_DTO)
        {
            result_DTO.Id    = result.Id;
            result_DTO.Score = result.Score;

            return(result_DTO);
        }
Ejemplo n.º 2
0
        public static Quiz_DTO ConvertQuizTo_DTO(Quiz quiz, ref Quiz_DTO quiz_DTO, IQuizRepo quizRepo)
        {
            quiz_DTO.Id           = quiz.Id;
            quiz_DTO.DifficultyId = quiz.DifficultyId;
            quiz_DTO.Subject      = quiz.Subject;
            quiz_DTO.Description  = quiz.Description;

            var diff = new Difficulty_DTO();

            quiz_DTO.Difficulty = ConvertDifficultyTo_DTO(quiz.Difficulty, ref diff);

            List <Question_DTO> question_DTOs = new List <Question_DTO>();

            //Questions
            foreach (Question question in quiz.Questions)
            {
                var obj = new Question_DTO();
                question_DTOs.Add(ConvertQuestionTo_DTO(question, obj, quizRepo).Result);
            }

            quiz_DTO.Questions = question_DTOs;

            List <Result_DTO> result_DTOs = new List <Result_DTO>();

            //results
            foreach (Result result in quiz.Results)
            {
                var obj = new Result_DTO();
                result_DTOs.Add(ConvertResultTo_DTO(result, ref obj));
            }

            quiz_DTO.Results = result_DTOs;

            return(quiz_DTO);
        }