Exemple #1
0
        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, "评论发表失败"));
            }
        }
Exemple #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)));
        }
        /// <summary>
        /// 新增评论
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool InsertArticleComment(ArticleCommentDataContract model)
        {
            string sql = @"INSERT INTO SA_ArticleComment(ArticleID,CommentContent,PostTime,UpdateTime,FlowerCount,EggCount,WarnCount,TableName,UserKeyId)
                           VALUES(@ArticleID,@CommentContent,@PostTime,@UpdateTime,@FlowerCount,@EggCount,@WarnCount,@TableName,@UserKeyId);SELECT @@IDENTITY;";

            var _parm = new SqlParameter[] {
                new SqlParameter("@ArticleID", model.ArticleID),
                new SqlParameter("@CommentContent", model.CommentContent),
                new SqlParameter("@PostTime", model.PostTime),
                new SqlParameter("@UpdateTime", model.UpdateTime),
                new SqlParameter("@FlowerCount", model.FlowerCount),
                new SqlParameter("@EggCount", model.EggCount),
                new SqlParameter("@WarnCount", model.WarnCount),
                new SqlParameter("@TableName", model.TableName),
                new SqlParameter("@UserKeyId", model.UserKeyId)
            };

            model.CommentID = Convert.ToInt64(SqlHelper.ExecuteScalar(SqlHelper.GetConnSting(), CommandType.Text, sql, _parm));

            return(model.CommentID > 0);
        }