public void Add(CommentLike commentLike)
{
var result = _commentLikesLogic.Add(commentLike);
if (result != null && result.Error != null) throw new Exception(result.Error.Message);
var parentComment = _commentsLogic.Get(commentLike.CommentId);
if (parentComment == null) throw new Exception(string.Format(
"Failed to like comment {0} due to error in fetching comment", commentLike.CommentId));
var commentLikes = _commentLikesLogic.Get(commentLike.CommentId);
if (commentLikes == null) throw new Exception(string.Format(
"Failed to like comment {0} due to error in fetching likes in comment", commentLike.CommentId));
var commentLikesUpdate = new CommentLikesUpdate
{
CommentId = commentLike.CommentId,
PostId = parentComment.PostId,
CommentLikes = commentLikes,
ClientFunction = Constants.SocketClientFunctions.CommentLikesUpdate.ToString()
};
_redisService.Publish(commentLikesUpdate);
}
}