public static CommentModel ToCommentModel(Comment commentEntity) { CommentModel commentModel = new CommentModel() { ID = commentEntity.ID, Author = commentEntity.Author.Nickname, Content = commentEntity.Content, Date = commentEntity.Date }; return commentModel; }
public static Comment ToCommentEntity( CommentModel commentModel, DbUsersRepository usersRepository, IRepository<NewsArticle> newsArticlesRepository) { Comment commentEntity = new Comment() { Content = commentModel.Content, Date = commentModel.Date, Author = usersRepository.GetByNickname(commentModel.Author) }; NewsArticle newsArticle = newsArticlesRepository.Get(commentModel.ArticleID); newsArticle.Comments.Add(commentEntity); return commentEntity; }
public static CommentModel ToCommentModel(Comment commentEntity) { CommentModel commentModel = new CommentModel() { ID = commentEntity.ID, Author = commentEntity.Author.Nickname, Content = commentEntity.Content, Date = commentEntity.Date }; foreach (Comment subComment in commentEntity.SubComments) { commentModel.SubComments.Add(new CommentDetails() { ID = subComment.ID, Author = subComment.Author.Nickname, Content = subComment.Content, Date = subComment.Date }); } return commentModel; }
public static Comment ToCommentEntity(CommentModel commentModel, DbUsersRepository usersRepository) { Comment commentEntity = new Comment() { ID = commentModel.ID, Content = commentModel.Content, Date = commentModel.Date, Author = usersRepository.GetByNickname(commentModel.Author) }; foreach (CommentDetails subComment in commentModel.SubComments) { commentEntity.SubComments.Add(new Comment() { ID = subComment.ID, Content = subComment.Content, Date = subComment.Date, Author = usersRepository.GetByNickname(subComment.Author) }); } return commentEntity; }