//public static List<Comment> Convert(List<CommentDTO> commentsDTO) //{ // List<Comment> comments = new List<Comment>(); // commentsDTO.ForEach(c => comments.Add(Convert(c))); // return comments; //} //public static List<CommentDTO> Convert(List<Comment> comments) //{ // List<CommentDTO> commentsDTO = new List<CommentDTO>(); // comments.ForEach(a => commentsDTO.Add(Convert(a))); // return commentsDTO; //} public static QuestionDTO Convert(Question question) { QuestionDTO questionDTO = new QuestionDTO() { Answers = question.Answers?.Select(a => Convert(a)).ToList(), QuestionDate = question.questionDate, QuestionId = question.questionId, QuestionTitle = question.questionTitle, Question_userId = question.question_userId, Requirement = question.requirement, //User = question.User, Votes = question.Votes?.Select(v => Convert(v)).ToList() }; questionDTO.Items = ConverterHelpers.GetQuestionItems(question.fileName); return(questionDTO); }
public static Question Convert(QuestionDTO question) { return(new Question() { Answers = question.Answers?.Select(a => Convert(a)).ToList(), fileName = ConverterHelpers.SaveQuestionItems(question.Items), questionDate = question.QuestionDate, questionId = question.QuestionId, questionTitle = question.QuestionTitle, question_userId = question.Question_userId, requirement = question.Requirement, Category_Question = question.Categories?.Select(c => new Category_Question { categoryId = c.CategoryId, questionId = question.QuestionId }).ToList(), //User = question.User, Votes = question.Votes?.Select(v => Convert(v)).ToList() }); }