Esempio n. 1
0
        private void transOne(ContentPost x, List <ContentSection> sections)
        {
            if (sections.Count == 0)
            {
                return;
            }

            // 0. 先更新post
            x.AppId       = sections[0].AppId;
            x.PageSection = sections[0];
            x.update();

            // 1. 删除旧有关系
            ContentPostSection.deleteBatch("PostId=" + x.Id);

            // 2. 挪到新section中
            foreach (ContentSection section in sections)
            {
                // 多对多处理
                ContentPostSection ps = new ContentPostSection();
                ps.Post    = x;
                ps.Section = section;
                ps.insert();
            }
        }
        public virtual void Update(ContentPost post, String sectionIds, String tagList)
        {
            if (db.update(post).IsValid)
            {
                post.Tag.Save(tagList);
            }

            List <ContentPostSection> oldPsList = ContentPostSection.find("PostId=" + post.Id).list();

            // 多对多处理
            ContentPostSection.deleteBatch("PostId=" + post.Id);

            ContentPostSection ps = new ContentPostSection();

            int[] ids = cvt.ToIntArray(sectionIds);
            foreach (int sectionId in ids)
            {
                ContentSection section = new ContentSection();
                section.Id = sectionId;

                ps.Post    = post;
                ps.Section = section;
                ps.insert();
            }

            post.PageSection    = new ContentSection(); // 不再使用旧版一对多关系
            post.PageSection.Id = ids[0];
            post.update();


            // 更新旧的section关系
            foreach (ContentPostSection p in oldPsList)
            {
                updateCachePostIds(p.Section.Id);
            }
            // 更新新的section关系
            foreach (int sectionId in ids)
            {
                updateCachePostIds(sectionId);
            }
        }
Esempio n. 3
0
        public virtual void Update(ContentPost post, String sectionIds, String tagList)
        {
            // 保存
            if (db.update(post).IsValid)
            {
                post.Tag.Save(tagList);
            }

            // 多对多处理
            ContentPostSection.deleteBatch("PostId=" + post.Id);
            ContentPostSection ps = new ContentPostSection();

            int[] ids = cvt.ToIntArray(sectionIds);
            foreach (int sectionId in ids)
            {
                ContentSection section = new ContentSection();
                section.Id = sectionId;
                ps.Post    = post;
                ps.Section = section;
                ps.insert();
            }
        }
Esempio n. 4
0
 public virtual void DeleteTrueBatch(string ids)
 {
     ContentPost.deleteBatch("Id in (" + ids + ")");
     ContentPostSection.deleteBatch("PostId in  in (" + ids + ")");
 }
Esempio n. 5
0
        public virtual void DeleteImg(ContentPost post)
        {
            ContentPostSection.deleteBatch("PostId=" + post.Id);

            db.delete(post);
        }