Exemplo n.º 1
0
        /// <summary>
        /// Recursive method builds website master pages and pages.
        /// </summary>
        /// <param name="tenantId">Identifies website being built.</param>
        /// <param name="page">Used to store identifier of page that will be created.</param>
        /// <param name="templatePage">Template page.</param>
        /// <param name="templateElements">Maintains dictionary of template elements and their corresponding master element copies.</param>
        /// <param name="navigationPages">List of pages that should be shown on site navigation.</param>
        /// <param name="unitOfWork">Unit of work.</param>
        private void BuildWebsite(long tenantId, Page page, TemplatePage templatePage, Dictionary <ElementKeyValue, ElementKeyValue> templateElements, List <Page> navigationPages, IUnitOfWork unitOfWork)
        {
            // Get master page from template page
            MasterPage masterPage = GetMasterPageFromTemplatePage(tenantId, page, templatePage, templateElements, unitOfWork);

            // Create master page
            long masterPageId = _masterPageRepository.Create(masterPage, unitOfWork);

            // We do not create page instances of administration master pages - these are created on the fly as needed
            if (!masterPage.Administration)
            {
                // Create page based on master page
                page.PageId = _pageService.Create(tenantId, page.ParentPageId, masterPageId, null, unitOfWork);
                page.Name   = masterPage.PageName;
                if (templatePage.ShowOnNavigation)
                {
                    navigationPages.Add(page);
                }
            }

            // Recursively create child pages
            foreach (TemplatePage childTemplatePage in templatePage.ChildTemplatePages)
            {
                Page childPage = new Page {
                    ParentPageId = page.PageId, ParentPage = page, TenantId = tenantId
                };
                BuildWebsite(tenantId, childPage, childTemplatePage, templateElements, navigationPages, unitOfWork);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new master page.
 /// </summary>
 /// <param name="masterPage">Contains details of new master page to create.</param>
 /// <param name="unitOfWork">Unit of work.</param>
 /// <returns>Newly allocated master page identifier.</returns>
 public long Create(MasterPage masterPage, IUnitOfWork unitOfWork = null)
 {
     return(_masterPageRepository.Create(masterPage, unitOfWork));
 }