예제 #1
0
파일: PageProvider.cs 프로젝트: zhq0131/CMS
        private void MovePageRecursively(Models.Site site, string pageFullName, string newParent, SiteDBContext dbContext)
        {
            var oldPage = Get(new Page(site, pageFullName));
            var entity  = PageEntityHelper.ToPageEntity <PageEntity>(oldPage);

            if (!string.IsNullOrEmpty(newParent))
            {
                var newPage = new Page(new Page(site, newParent), oldPage.Name);
                entity.FullName   = newPage.FullName;
                entity.ParentPage = newPage.Parent.FullName;
            }
            else
            {
                entity.FullName   = oldPage.Name;
                entity.ParentPage = "";
            }

            dbContext.Pages.Add(entity);

            foreach (var item in ChildPages(oldPage))
            {
                MovePageRecursively(site, item.FullName, entity.FullName, dbContext);
            }

            var oldEntity = dbContext.Pages
                            .Where(it => it.SiteName == oldPage.Site.FullName && it.FullName == oldPage.FullName)
                            .FirstOrDefault();

            if (oldEntity != null)
            {
                dbContext.Pages.Remove(oldEntity);
            }
        }
예제 #2
0
파일: PageProvider.cs 프로젝트: zhq0131/CMS
        public void SaveAsDraft(Models.Page page)
        {
            var entity = _dbContext.PageDrafts
                         .Where(it => it.SiteName == page.Site.FullName && it.FullName == page.FullName)
                         .FirstOrDefault();

            if (entity != null)
            {
                PageEntityHelper.ToPageEntity(page, entity);
            }
            else
            {
                _dbContext.PageDrafts.Add(PageEntityHelper.ToPageEntity <PageDraftEntity>(page));
            }

            _dbContext.SaveChanges();
        }
예제 #3
0
파일: PageProvider.cs 프로젝트: zhq0131/CMS
        public Models.Page Copy(Models.Site site, string sourcePageFullName, string newPageFullName)
        {
            var page    = Get(new Page(site, sourcePageFullName));
            var newPage = new Page(site, newPageFullName);
            var entity  = PageEntityHelper.ToPageEntity <PageEntity>(page);

            entity.FullName = newPageFullName;
            if (newPage.Parent != null)
            {
                entity.ParentPage = newPage.Parent.FullName;
            }

            _dbContext.Pages.Add(entity);
            _dbContext.SaveChanges();

            ClearCache();

            return(PageEntityHelper.ToPage(entity));
        }
예제 #4
0
파일: PageProvider.cs 프로젝트: zhq0131/CMS
        private void InsertOrUpdate(Models.Page @new, Models.Page old)
        {
            @new.OnSaving();

            var entity = _dbContext.Pages
                         .Where(it => it.SiteName == old.Site.FullName && it.FullName == old.FullName)
                         .FirstOrDefault();

            if (entity != null)
            {
                PageEntityHelper.ToPageEntity(@new, entity);
            }
            else
            {
                _dbContext.Pages.Add(PageEntityHelper.ToPageEntity <PageEntity>(@new));
            }
            _dbContext.SaveChanges();
            ClearCache();
        }
예제 #5
0
파일: PageProvider.cs 프로젝트: zhq0131/CMS
        private void LocalizeWithChildPages(SiteDBContext dbContext, Page page, Site targetSite)
        {
            var entity = dbContext.Pages
                         .Where(it => it.SiteName == targetSite.FullName && it.FullName == page.FullName)
                         .FirstOrDefault();

            if (entity == null)
            {
                page = Get(page);

                entity          = PageEntityHelper.ToPageEntity <PageEntity>(page);
                entity.SiteName = targetSite.FullName;

                dbContext.Pages.Add(entity);

                foreach (var item in ChildPages(page))
                {
                    LocalizeWithChildPages(dbContext, item, targetSite);
                }
            }
        }