Exemple #1
0
        /// <summary>
        /// 修改文章
        /// </summary>
        /// <param name="_postinfo"></param>
        /// <returns></returns>
        public static int UpdatePost(PostInfo _postinfo)
        {
            //   PostInfo oldPost = GetPost(_postinfo.PostId);   //好像有问题,不能缓存

            PostInfo oldPost = GetPostByDatabase(_postinfo.PostId);

            int result = DatabaseProvider.Instance.UpdatePost(_postinfo);

            if (oldPost != null && oldPost.CategoryId != _postinfo.CategoryId)
            {
                //分类
                CategoryService.UpdateCategoryCount(oldPost.CategoryId, -1);
                CategoryService.UpdateCategoryCount(_postinfo.CategoryId, 1);
            }

            //     CacheHelper.Remove(CacheKey);

            //标签
            TagService.UpdateTagUseCount(oldPost.Tag, -1);
            TagService.UpdateTagUseCount(_postinfo.Tag, 1);

            //   RemovePostsCache();

            return(result);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }