Ejemplo n.º 1
0
        /// <summary>
        /// 根据日志ID删除评论
        /// </summary>
        /// <param name="postId">日志ID</param>
        /// <returns></returns>
        public static int DeleteCommentByPost(int postId)
        {
            int result = dao.DeleteCommentByPost(postId);

            StatisticsManager.UpdateStatisticsCommentCount(-result);

            _recentcomments = null;

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public static int InsertComment(CommentInfo comment)
        {
            int result = dao.InsertComment(comment);

            //统计
            StatisticsManager.UpdateStatisticsCommentCount(1);

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

            //文章
            PostManager.UpdatePostCommentCount(comment.PostId, 1);


            _recentcomments = null;

            return(result);
        }
Ejemplo n.º 3
0
        ///// <summary>
        ///// 移动所有文章缓存
        ///// </summary>
        ///// <returns></returns>
        //private static bool RemovePostsCache()
        //{
        ////    Caches.Remove("/posts");

        //    return true;
        //}

        /// <summary>
        /// 添加文章
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public static int InsertPost(PostInfo post)
        {
            post.PostId = dao.InsertPost(post);

            _posts.Add(post);
            _posts.Sort();

            //统计
            StatisticsManager.UpdateStatisticsPostCount(1);
            //用户
            UserManager.UpdateUserPostCount(post.UserId, 1);
            //分类
            CategoryManager.UpdateCategoryCount(post.CategoryId, 1);
            //标签
            TagManager.UpdateTagUseCount(post.Tag, 1);

            //   RemovePostsCache();

            return(post.PostId);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="commentId"></param>
        /// <returns></returns>
        public static int DeleteComment(int commentId)
        {
            CommentInfo comment = GetComment(commentId);

            int result = dao.DeleteComment(commentId);

            //统计
            StatisticsManager.UpdateStatisticsCommentCount(-1);

            if (comment != null)
            {
                //用户
                UserManager.UpdateUserCommentCount(comment.UserId, -1);
                //文章
                PostManager.UpdatePostCommentCount(comment.PostId, -1);
            }

            _recentcomments = null;

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 删除文章
        /// </summary>
        /// <param name="postid"></param>
        /// <returns></returns>
        public static int DeletePost(int postid)
        {
            PostInfo oldPost = GetPost(postid);

            _posts.Remove(oldPost);

            int result = dao.DeletePost(postid);

            //统计
            StatisticsManager.UpdateStatisticsPostCount(-1);
            //用户
            UserManager.UpdateUserPostCount(oldPost.UserId, -1);
            //分类
            CategoryManager.UpdateCategoryCount(oldPost.CategoryId, -1);
            //标签
            TagManager.UpdateTagUseCount(oldPost.Tag, -1);

            //删除所有评论
            CommentManager.DeleteCommentByPost(postid);

            //     RemovePostsCache();

            return(result);
        }