Beispiel #1
0
 public QuestionDTO(Question question, int dtolevel = 0)
 {
     ID           = question.ID;
     UserID       = question.UserID;
     CategoryID   = question.CategoryID;
     Title        = question.Title;
     QuestionBody = question.QuestionBody;
     Added        = question.Added;
     Score        = question.Score;
     Bounty       = question.Bounty;
     Modified     = question.Modified;
     Views        = question.QuestionViews.Count;
     Tags         = question.Tags.Select(TagDTO.FromEntity).ToList();
     //Tags = (from tag in question.Tags select new TagDTO(tag)).ToList();
     AnswersNumber = question.Answers.Count;
     if (dtolevel == 0)
     {
         Answers = question.Answers.Select(answer => AnswerDTO.FromEntity(answer, dtolevel)).ToList();
     }
     //Anwsers = (from ans in question.Answers select new AnswerDTO(ans)).ToList();
     if (dtolevel == 0)
     {
         Comments = question.Comments.Select(CommentDTO.FromEntity).ToList();
     }
     AspNetUser = new AspNetUserDTO(question.AspNetUser, 1);
     Category   = new CategoryDTO(question.Category);
 }
Beispiel #2
0
 public CommentDTO(Comment comment)
 {
     ID          = comment.ID;
     ParentID    = comment.ParentID;
     UserID      = comment.UserID;
     Score       = comment.Score;
     CommentBody = comment.CommentBody;
     Added       = comment.Added;
     Modified    = comment.Modified;
     AspNetUser  = new AspNetUserDTO(comment.AspNetUser, 1);
 }
Beispiel #3
0
 public AnswerDTO(Answer answer, int dtolevel = 0)
 {
     ID         = answer.ID;
     UserID     = answer.UserID;
     QuestionID = answer.QuestionID;
     AnswerBody = answer.AnswerBody;
     Score      = answer.Score;
     Added      = answer.Added;
     AspNetUser = new AspNetUserDTO(answer.AspNetUser, 1);
     if (dtolevel == 0)
     {
         Comments = answer.Comments.Select(CommentDTO.FromEntity).ToList();
     }
     Accepted = answer.Accepted;
     //Comments = (from com in answer.Comments select new CommentDTO(com)).ToList();
 }