public List<Comment> GetByPostId(int postId)
{
var comments = new List<Comment>();
try
{
var db = _commentRepository.Find(a => a.PostId == postId, null, "ParentComment,CommentLikes,User").OrderByDescending(a => a.CreatedDate).ToList();
db.ForEach(a => comments.Add(CommentMapper.ToDto(a)));
comments.ForEach(a => a.Comments = GetReplies(a.Id));
}
catch (Exception ex)
{
throw new BlogException(ex.Message, ex.InnerException);
}
return comments;
}