/// <summary> /// Trasnforme une question en FindQuizzQuestionsDto /// </summary> /// <param name="question">question à transformer</param> /// <param name="idAnswerCandidate">id de la réponse du candidat</param> /// <returns>FindQuizzQuestionsDto</returns> private FindQuizzQuestionsDto TransformsModelToDTOQuestion(Question question, string answerCandidate, bool?isCorrectAnswer) { CategoryRepository catRepo = new CategoryRepository(new QueryBuilder()); FindAnswerDto answer = AnswersServices.GetAnswerById((int)question.IdAnswer); return(new FindQuizzQuestionsDto( question.IdQuestion, question.Intitule, catRepo.Find((int)question.IdCategory).NameCategory, TransformeIdLevelToString((int)question.IdLevel), answer, answerCandidate, isCorrectAnswer )); }
/// <summary> /// Converti un Model en DTO /// </summary> /// <param name="question"></param> /// <returns>Une question en DTO</returns> private FindQuestionsDto TransformsModelToDTO(Question question, FindAnswerDto answer = null) { LevelRepository lvlRepo = new LevelRepository(new QueryBuilder()); CategoryRepository catRepo = new CategoryRepository(new QueryBuilder()); // Si answer est inconnu alors aller le récupérer à l'aide de service answer et rappel la méthode if (answer == null) { return(TransformsModelToDTO(question, AnswerServices.GetAnswerById((int)question.IdAnswer))); } return(new FindQuestionsDto( question.IdQuestion, question.Intitule, catRepo.Find((int)question.IdCategory).NameCategory, lvlRepo.Find((int)question.IdLevel).NameLevel, answer )); }