コード例 #1
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="commentId"></param>
 /// <returns></returns>
 public int Delete(CommentInfo comment)
 {
     string cmdText = string.Format("delete from [{0}comments] where [commentId] = @commentId", ConfigHelper.Tableprefix);
     using (var conn = new DapperHelper().OpenConnection())
     {
         return conn.Execute(cmdText, new { commentId = comment.CommentId });
     }
 }
コード例 #2
0
 public ActionResult Add(CommentInfo comment)
 {
     return Content("success");
 }
コード例 #3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public int Update(CommentInfo comment)
        {
            string cmdText = string.Format(@"update [{0}comments] set
                            PostId=@PostId,
                            ParentId=@ParentId,
                            UserId=@UserId,
                            Author=@Author,
                            Email=@Email,
                            AuthorUrl=@AuthorUrl,
                            Contents=@Contents,
                            EmailNotify=@EmailNotify,
                            IpAddress=@IpAddress,
                            CreateTime=@CreateTime,
                            Approved=@Approved
                            where CommentId=@CommentId ", ConfigHelper.Tableprefix);

            using (var conn = new DapperHelper().OpenConnection())
            {
               return conn.Execute(cmdText, comment);
            }
        }
コード例 #4
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="comment"></param>
 /// <returns></returns>
 public int Insert(CommentInfo comment)
 {
     string cmdText = string.Format(@"insert into [{0}comments](
                     PostId, ParentId,UserId,Author,Email,AuthorUrl,Contents,EmailNotify,IpAddress,CreateTime,Approved)
                      values (
                     @PostId, @ParentId,@UserId,@Author,@Email,@AuthorUrl,@Contents,@EmailNotify,@IpAddress,@CreateTime,@Approved)", ConfigHelper.Tableprefix);
     using (var conn = new DapperHelper().OpenConnection())
     {
         conn.Execute(cmdText, comment);
         return conn.Query<int>(string.Format("select  [CommentId] from [{0}comments]  order by [CommentId] desc limit 1", ConfigHelper.Tableprefix), null).First();
     }
 }
コード例 #5
0
ファイル: CommentService.cs プロジェクト: robotbird/jqpress
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public int UpdateComment(CommentInfo comment)
        {
            _recentcomments = null;

            return _commentRepository.Update(comment);
        }
コード例 #6
0
ファイル: CommentService.cs プロジェクト: robotbird/jqpress
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public int InsertComment(CommentInfo comment)
        {
            int result = _commentRepository.Insert(comment);

            //统计
            new StatisticsService().UpdateStatisticsCommentCount(1);

            //用户
            new UserService().UpdateUserCommentCount(comment.UserId, 1);

            //文章
            //TODO:postservice
            //PostService.UpdatePostCommentCount(comment.PostId, 1);

            _recentcomments = null;

            return result;
        }