Esempio n. 1
0
        /// <summary>
        /// 添加文章
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public static int InsertPost(PostInfo post)
        {
            post.PostId = DatabaseProvider.Instance.InsertPost(post);

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

            //统计
            StatisticsService.UpdateStatisticsPostCount(1);
            //用户
            UserService.UpdateUserPostCount(post.UserId, 1);
            //分类
            CategoryService.UpdateCategoryCount(post.CategoryId, 1);
            //标签
            TagService.UpdateTagUseCount(post.Tag, 1);

            //   RemovePostsCache();

            return(post.PostId);
        }
Esempio n. 2
0
        /// <summary>
        /// 删除文章
        /// </summary>
        /// <param name="postid"></param>
        /// <returns></returns>
        public static int DeletePost(int postid)
        {
            PostInfo oldPost = GetPost(postid);

            _posts.Remove(oldPost);

            int result = DatabaseProvider.Instance.DeletePost(postid);

            //统计
            StatisticsService.UpdateStatisticsPostCount(-1);
            //用户
            UserService.UpdateUserPostCount(oldPost.UserId, -1);
            //分类
            CategoryService.UpdateCategoryCount(oldPost.CategoryId, -1);
            //标签
            TagService.UpdateTagUseCount(oldPost.Tag, -1);

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

            //     RemovePostsCache();

            return(result);
        }