Exemple #1
0
        public static void DeleteTopic(ForumTopic topic)
        {
            ForumApp app = ForumApp.findById(topic.AppId);

            if (app == null)
            {
                return;
            }

            List <StickyTopic> stickyList   = GetTopics(app.StickyTopic);
            List <StickyTopic> list         = new List <StickyTopic>();
            Boolean            shouldDelete = false;

            foreach (StickyTopic x in stickyList)
            {
                if (x.Id == topic.Id)
                {
                    shouldDelete = true;
                    continue;
                }
                list.Add(x);
            }

            if (shouldDelete)
            {
                String newJson = Json.ToStringList(list);
                app.StickyTopic = newJson;
                app.update();
            }
        }
Exemple #2
0
        //---------------------------------------- 减少置顶的帖子 ---------------------------------------------------------

        public static void DeleteTopic(long appId, string ids)
        {
            ForumApp app = ForumApp.findById(appId);

            if (app == null)
            {
                return;
            }
            List <StickyTopic> stickyList   = GetTopics(app.StickyTopic);
            List <StickyTopic> list         = new List <StickyTopic>();
            Boolean            shouldDelete = false;

            long[] arrIds = cvt.ToLongArray(ids);

            foreach (StickyTopic x in stickyList)
            {
                if (containsTopicId(arrIds, x.Id))
                {
                    shouldDelete = true;
                    continue;
                }
                list.Add(x);
            }

            if (shouldDelete)
            {
                String newJson = Json.ToStringList(list);
                app.StickyTopic = newJson;
                app.update();
            }
        }