private Page <Hub> PopulatePageModel(PageRoot cmsContent)
        {
            var pageModel = new Page <Hub>
            {
                Slug        = cmsContent.Hub.PageAttributes.Slug,
                HubType     = Enum.Parse <HubType>(cmsContent.Hub.PageAttributes.HubType),
                Title       = cmsContent.Hub.PageAttributes.Title,
                MetaContent = new MetaContent
                {
                    MetaDescription = cmsContent.Hub.PageAttributes?.MetaDescription,
                    PageTitle       = cmsContent.Hub.PageAttributes.Title
                },
                Content = new Hub
                {
                    Summary = cmsContent.Hub.PageAttributes.Summary
                }
            };

            pageModel.PopulateMenuModel(cmsContent.Hub.MenuContent);
            pageModel.AddBannerContent(_controlAbstractFactory, cmsContent.Hub.BannerModels);
            AddHeaderImage(cmsContent, pageModel);
            AddCards(cmsContent, pageModel);

            return(pageModel);
        }
Esempio n. 2
0
        private Page <Menu> PopulatePageModel(PageRoot cmsContent)
        {
            var pageModel = new Page <Menu>();

            pageModel.PopulateMenuModel(cmsContent);

            return(pageModel);
        }
        private Page <BannerContentType> PopulatePageModel(PageRoot cmsContent)
        {
            var pageModel = new Page <BannerContentType>();

            pageModel.AddBannerContent(_controlAbstractFactory, cmsContent.Banner);

            return(pageModel);
        }
        private static void AddCards(PageRoot cmsContent, Page <LandingPage> model)
        {
            if (cmsContent.LandingPage.MainContent.Cards == null || !cmsContent.LandingPage.MainContent.Cards.Any())
            {
                return;
            }

            model.Content.Cards = cmsContent.LandingPage.MainContent.Cards;
        }
 private void AddHeaderImage(PageRoot cmsContent, Page <LandingPage> model)
 {
     model.Content.HeaderImage = new Image
     {
         Description = cmsContent.LandingPage.MainContent?.HeaderImage?.EmbeddedResource.Description,
         Title       = cmsContent.LandingPage.MainContent?.HeaderImage?.EmbeddedResource.Title,
         Url         = cmsContent.LandingPage.MainContent?.HeaderImage?.EmbeddedResource.Url
     };
 }
Esempio n. 6
0
 internal static void PopulateMenuModel <T>(this Page <T> page, PageRoot cmsContent) where T : IContentType
 {
     page.Menu = new Menu
     {
         Apprentices = cmsContent.Menu.MainContent.Apprentices.AddSiteMapUrls(),
         Employers   = cmsContent.Menu.MainContent.Employers.AddSiteMapUrls(),
         Influencers = cmsContent.Menu.MainContent.Influencers.AddSiteMapUrls(),
         TopLevel    = cmsContent.Menu.MainContent.TopLevel.AddSiteMapUrls()
     };
 }
Esempio n. 7
0
        private Page <SiteMap> PopulatePageModel(PageRoot cmsContent)
        {
            var pageModel = new Page <SiteMap>
            {
                Content = new SiteMap
                {
                    Urls = AddSiteMapUrls(cmsContent)
                }
            };

            return(pageModel);
        }
        private void AddBreadCumbs(PageRoot cmsContent, Page <Article> model)
        {
            if (cmsContent.Article.ParentPage == null)
            {
                return;
            }

            model.Breadcrumbs = new Breadcrumbs
            {
                LandingPageSlug = cmsContent.Article.ParentPage.Slug,
                HubPage         = cmsContent.Article.ParentPage.HubType,
                LandingPage     = cmsContent.Article.ParentPage.Title
            };
        }
        private static void AddAttachments(PageRoot cmsContent, Page <Article> model)
        {
            if (cmsContent.Article.Attachments == null || !cmsContent.Article.Attachments.Any())
            {
                return;
            }

            var attachments = cmsContent.Article.Attachments.Select(attach => new DocumentAttachment
            {
                Description = attach.Description,
                FileSize    = attach.Size,
                Url         = attach.Url,
                Title       = attach.Title,
                FileType    = attach.ContentType
            }).ToList();

            model.Attachments = attachments;
        }
        private static void AddRelatedArticles(PageRoot cmsContent, Page <Article> model)
        {
            if (cmsContent.Article.RelatedArticles == null || !cmsContent.Article.RelatedArticles.Any())
            {
                return;
            }

            var relatedPages = cmsContent.Article.RelatedArticles.Select(relatedArticle => new ArticleRelated()
            {
                Summary     = relatedArticle.Summary,
                HubType     = relatedArticle.HubType,
                Slug        = relatedArticle.Slug,
                Description = relatedArticle.MetaDescription,
                Title       = relatedArticle.Title
            }).ToList();

            model.RelatedPages = relatedPages;
        }
        private void AddPageContent(PageRoot cmsContent, Page <Article> model)
        {
            var pageContent = new List <IHtmlControl>();

            foreach (var content in cmsContent.Article.MainContent.Items)
            {
                var factory = _controlAbstractFactory.CreateControlFactoryFor(content);

                if (factory == null)
                {
                    continue;
                }

                pageContent.Add(factory.Create(content));
            }

            model.Content = new Article
            {
                PageControls = pageContent, Summary = cmsContent.Article.PageAttributes.Summary
            };
        }
        private void AddTabbedContent(PageRoot cmsContent, Page <Article> model)
        {
            if (cmsContent.Article?.TabbedContents == null)
            {
                return;
            }

            var tabbedContents = new List <TabbedContent>();

            foreach (var responseTabbedContent in cmsContent.Article.TabbedContents)
            {
                var content = new TabbedContent
                {
                    TabName         = responseTabbedContent.TabName,
                    TabTitle        = responseTabbedContent.TabTitle,
                    FindTraineeShip = responseTabbedContent.FindTraineeship
                };

                var pageContent = new List <IHtmlControl>();

                foreach (var tabContent in responseTabbedContent.Content.Items)
                {
                    var factory = _controlAbstractFactory.CreateControlFactoryFor(tabContent);

                    if (factory == null)
                    {
                        continue;
                    }

                    pageContent.Add(factory.Create(tabContent));
                }

                content.Content = pageContent;
                tabbedContents.Add(content);
            }

            model.Content.TabbedContents = tabbedContents;
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            if (reader.TokenType == JsonToken.Null)
            {
                return(null);
            }

            var jObject    = JObject.Load(reader);
            var cmsContent = new PageRoot();

            serializer.Populate(jObject.CreateReader(), cmsContent);

            return(PopulatePageModel(cmsContent));
        }
        private Page <Article> PopulatePageModel(PageRoot cmsContent)
        {
            var pageModel = new Page <Article>
            {
                Slug        = cmsContent.Article.PageAttributes.Slug,
                HubType     = Enum.Parse <HubType>(cmsContent.Article.PageAttributes.HubType),
                Title       = cmsContent.Article.PageAttributes.Title,
                MetaContent = new MetaContent
                {
                    MetaDescription = cmsContent.Article.PageAttributes.MetaDescription,
                    PageTitle       = cmsContent.Article.PageAttributes.Title
                }
            };

            AddRelatedArticles(cmsContent, pageModel);
            AddPageContent(cmsContent, pageModel);
            AddAttachments(cmsContent, pageModel);
            AddBreadCumbs(cmsContent, pageModel);
            pageModel.AddBannerContent(_controlAbstractFactory, cmsContent.Article.BannerModels);
            AddTabbedContent(cmsContent, pageModel);
            pageModel.PopulateMenuModel(cmsContent.Article.MenuContent);

            return(pageModel);
        }
Esempio n. 15
0
 private List <Url> AddSiteMapUrls(PageRoot cmsContent)
 {
     return(cmsContent.Map.MainContent.Pages.Select(page => new Url {
         Title = page.Title, Hub = page.Hub, PageType = page.PageType, Slug = page.Slug, ParentSlug = page.ParentSlug
     }).ToList());
 }