Пример #1
0
 public static QuestionAnswer ToAnswer(QuestionAnswerDTO quest)
 {
     return(new QuestionAnswer
     {
         Id = quest.Id,
         Title = quest.Title,
         QuestionId = quest.QuestionId,
         UserId = quest.UserId,
     });
 }
Пример #2
0
 public static QuestionDTO ToQuestionDTO(Question quest)
 {
     return(new QuestionDTO
     {
         Id = quest.Id,
         Title = quest.Title,
         CategoryId = quest.CategoryId,
         UserId = quest.UserId,
         UserName = quest.User != null ? quest.User.UserName : quest.AnonymousName,
         AnonymousEmail = quest.AnonymousEmail,
         AnonymousName = quest.AnonymousName,
         Answers = quest.Answers.Select(s => QuestionAnswerDTO.ToAnswerDTO(s)),
         IsAnswered = quest.Answers.Any(),
         ProfileImg = quest.User == null || string.IsNullOrEmpty(quest.User.ProfileImg) ? "/images/personal-img.jpg" : quest.User.ProfileImg,
     });
 }