示例#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();
            }
        }
示例#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();
            }
        }
示例#3
0
        //-------------------------------------------------------------------------------------------------

        public static List <ForumTopic> GetForumTopic(String json, ForumApp app)
        {
            List <StickyTopic> stickyList = GetTopics(json);

            List <ForumTopic> results = new List <ForumTopic>();

            foreach (StickyTopic st in stickyList)
            {
                ForumTopic topic = getTopicBySticky(st, app.OwnerId, app.OwnerType, app.OwnerUrl);
                results.Add(topic);
            }

            return(results);
        }