Exemplo n.º 1
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);
        }
Exemplo 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 = 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);
        }