コード例 #1
0
        public virtual void DeleteTrue(ForumTopic topic, User viewer, String ip)
        {
            // 作者的帖子数
            int creatorId = topic.Creator.Id;

            userService.DeletePostCount(creatorId);

            // 帖子本身和tag
            topic.Tag.DeleteTags();
            db.delete(topic);

            // 主题相关的post
            ForumPost postByTopic = GetPostByTopic(topic.Id);
            //postByTopic.delete();
            List <ForumPost> posts = db.find <ForumPost>("TopicId=" + topic.Id).list();

            foreach (ForumPost p in posts)
            {
                db.delete(p);
            }

            // 相关的附件
            int postId = postByTopic.Id;

            AttachmentService.DeleteByPost(postId);

            // 更新板块的统计
            //int replies = topic.Replies;
            //int forumBoardId = topic.ForumBoard.Id;
            //boardService.DeleteTopicCount( forumBoardId, replies, topic.OwnerId );

            logService.AddTopic(viewer, topic.AppId, topic.Id, ForumLogAction.DeleteTrue, ip);
        }