public ReturnResult<long> InsertArticleComment(ArticleCommentDataContract model, int articleCategoryId)
        {
            if (null == model)
            {
                return new ReturnResult<long>(101, 0, "参数异常,未找到数据");
            }
            if (string.IsNullOrWhiteSpace(model.CommentContent))
            {
                return new ReturnResult<long>(102, 0, "参数异常,内容不允许为空");
            }
            int rootCategoryId = articleCategoryService.GetRootCategoryId(articleCategoryId);

            if (rootCategoryId == -1)
            {
                return new ReturnResult<long>(103, 0, "参数异常,文章分类错误");
            }

            model.PostTime = DateTime.Now;
            model.UpdateTime = DateTime.Now;
            model.TableName = "SA_ArticleContent" + rootCategoryId;

            if (ArticleCommentRepository.Instance.InsertArticleComment(model))
            {
                System.Threading.Tasks.Task.Factory.StartNew(() => articleContentService.UpdateArticleCount(model.ArticleID, articleCategoryId, model.UserKeyId, ArticleCountEnum.CommentCount));
                return new ReturnResult<long>(model.CommentID);
            }
            else
            {
                return new ReturnResult<long>(104, 0, "评论发表失败");
            }
        }
Example #2
0
 public JsonResult PublishComment(OauthToken token, long articleId, int articleCategoryId, string content)
 {
     var comment = new ArticleCommentDataContract()
     {
         ArticleID = articleId,
         CommentContent = System.Web.HttpUtility.UrlDecode(content)
     };
     comment.UserKeyId = token.UserKeyId;
     return Json(articleCommentService.InsertArticleComment(comment, articleCategoryId));
 }