public Comment AddComment(string blogName, string userName, string email, string comment, int?replyId = null) { var blogPost = _blogRepository.GetBlogByName(blogName); if (blogPost != null) { var cmt = _commentRepository.AddComment(new Comment() { BlogItemId = blogPost.Id, Content = comment, ParentId = replyId, SubCommentCount = 0, Username = userName, Email = email, DateSent = DateTime.Now }); if (replyId != null) { UpdateSubCommentCount(replyId.Value); } _commentRepository.SaveChanges(); return(cmt); } return(null); }