public static Answer_DTO ConvertAnswerTo_DTO(Answer answer, ref Answer_DTO answer_DTO) { answer_DTO.Id = answer.Id; answer_DTO.Description = answer.Description; answer_DTO.FotoURL = answer.FotoURL; if (answer.Correct.ToString() == "True") { answer_DTO.Correct = Answer_DTO.IsCorrect.True; } else { answer_DTO.Correct = Answer_DTO.IsCorrect.False; } return(answer_DTO); }
public async static Task <Question_DTO> ConvertQuestionTo_DTO(Question question, Question_DTO question_DTO, IQuizRepo quizRepo) { question_DTO.Id = question.Id; question_DTO.Description = question.Description; var result = await quizRepo.GetAllAnswersByQuestionId(question.Id); List <Answer_DTO> answer_DTOs = new List <Answer_DTO>(); //Answers foreach (Answer answer in result) { var obj = new Answer_DTO(); answer_DTOs.Add(ConvertAnswerTo_DTO(answer, ref obj)); } question_DTO.Answers = answer_DTOs; return(question_DTO); }