public int Add(WebArticleCommentDto model)
 {
     var id = 0;
     var isReply = false;
     //如果为回复别人的 分页数则为父级分页数
     if (model.ParentID > 0)
     {
         if (model.IsTopReply) //如果回复的为第一级
         {
             var parentModel = _acticleCommentRepository.GetModel(t => t.ID == model.ParentID);
             if (parentModel == null || parentModel.ID == 0)
                 return 0;
         }
         else//如果回复的为不是第一级(回复的回复表)
         {
             var parentModel = _articleReplyCommentRepository.GetModel(t => t.ID == model.ParentID);
             if (parentModel == null || parentModel.ID == 0)
                 return 0;
         }
         var replyModel = new ArticleReplyComment
         {
             ActicleID = model.ArticleID,
             Content = model.Content,
             CreateTime = DateTime.Now,
             IsDel = false,
             LikeCount = 0,
             ParentID = model.ParentID,
             TopParentID = model.TopParentID,
             UserID = model.UserID,
             IsTopReply = false
         };
         _articleReplyCommentRepository.Insert(replyModel);
         //更新顶级回复的回复数量
         if (model.TopParentID > 0)
         {
             Task.Factory.StartNew(() =>
             {
                 _articleRepository.UpdateRelpayCount(model.TopParentID);
             });
         }
         id = replyModel.ID;
         isReply = true;
     }
     else
     {
         var commentModel = new ArticleComment
         {
             ArticleID = model.ArticleID,
             ArticleName = model.ArticleName,
             Content = model.Content,
             CreateTime = DateTime.Now,
             IsDel = false,
             LikeCount = 0,
             UserID = model.UserID
         };
         _acticleCommentRepository.Insert(commentModel);
         id = commentModel.ID;
     }
     if (id > 0)
     {
         Task.Factory.StartNew(() =>
         {
             //更新评论数
             _articleRepository.UpdateRelpayCount(model.ArticleID);
             if (model.ParentID > 0)
             {
                 _messageRemindRepository.Insert(new MessageRemind
                 {
                     UserID = model.UserID,
                     Type = (int)ProjectEnum.文章,
                     IsLook = false,
                     IsDel = false,
                     IsReply = isReply,
                     DataID = id,
                     CreateTime = DateTime.Now
                 });
             }
         });
     }
     return id;
 }
 public JsonResult Comment(int id, string content, int? parentid, int? topparent, int? depth)
 {
     if (id <= 0 || string.IsNullOrEmpty(content) ||
         (parentid.HasValue && (!topparent.HasValue || topparent.Value <= 0)))
         return JsonMsg(false, Msg.ArgumentError);
     var data = new WebArticleCommentDto
     {
         ArticleID = id,
         Content = content,
         ParentID = parentid ?? 0,
         UserID = CurrentUser.ID,
         TopParentID = topparent??0,
         IsTopReply = depth==1
     };
     var result = _acticleCommentService.Add(data);
     if (result > 0)
     {
         return Json(new
         {
             Result = true,
             CreateTime = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss"),
             ID = result,
             Comment_UserId = CurrentUser.ID,
             UserName = CurrentUser.UName,
             UserAvatar = CurrentUser.Image,
             Content = content,
             ActicleID = id,
             TopParentID = topparent,
         });
     }
     return JsonMsg(false, Msg.CommentError);
 }