public CommentViewModel GetCommentByCommentId(string commentId) { var comment = this._db.Comments.ToList().Find(cmt => cmt.CommentId == commentId); IUserRepository userRepository = new UserRepository(this._db); var userOwner = userRepository.GetUserById(comment.UserId); ILikeCommentRepositoty likeCommentRepository = new LikeCommentRepository(this._db); var listUserLiked = likeCommentRepository.GetListUserLikedComment(commentId); return new CommentViewModel { CommentId = comment.CommentId, TimeCommented = comment.TimeComment, Content = ProcessComment.ProcessMessage(comment.Content), UserOwner = userOwner, ListUserLiked = listUserLiked }; }
public CommentViewModel GetCommentByCommentId(string commentId) { var comment = this._db.Comments.ToList().Find(cmt => cmt.CommentId == commentId); IUserRepository userRepository = new UserRepository(this._db); var userOwner = userRepository.GetUserById(comment.UserId); ILikeCommentRepositoty likeCommentRepository = new LikeCommentRepository(this._db); var listUserLiked = likeCommentRepository.GetListUserLikedComment(commentId); return (new CommentViewModel { CommentId = comment.CommentId, TimeCommented = comment.TimeComment, Content = ProcessComment.ProcessMessage(comment.Content), UserOwner = userOwner, ListUserLiked = listUserLiked }); }