public static Db.Comment ToEntity(Comment comment)
{
if (comment != null)
{
var commentLikes = comment.CommentLikes != null
? comment.CommentLikes.Select(CommentLikeMapper.ToEntity).ToList()
: null;
var comments = comment.Comments != null
? comment.Comments.Select(ToEntity).ToList()
: null;
if (comment.User != null)
return new Db.Comment
{
CommentId = comment.Id,
CommentLikes = commentLikes,
CommentLocation = comment.CommentLocation,
CommentMessage = comment.CommentMessage,
ParentCommentId = comment.ParentCommentId,
PostId = comment.PostId,
Comments = comments,
User = UserMapper.ToEntity(comment.User),
UserId = comment.User.Id,
CreatedBy = comment.CreatedBy,
CreatedDate = comment.CreatedDate,
ModifiedBy = comment.ModifiedBy,
ModifiedDate = comment.ModifiedDate
};
}
return null;
}
}