Example #1
0
        private ScienceLatestUpdatesSectionViewModel GetLatestUpdates(ScienceLandingPage model)
        {
            var viewModel = new ScienceLatestUpdatesSectionViewModel()
            {
                Pages        = GetLatestUpdatedPages(model),
                AToZPageLink = _navigationItemService.GetViewModel(model.AToZpageLink)
            };

            return(viewModel);
        }
        public IEnumerable <CalloutCardViewModel> GetCalloutCards(IEnumerable <CalloutCardSchema> cards)
        {
            var viewModels = new List <CalloutCardViewModel>();

            if (ExistenceUtility.IsNullOrEmpty(cards))
            {
                return(viewModels);
            }

            foreach (var card in cards)
            {
                var viewModel = new CalloutCardViewModel()
                {
                    Title          = card.Title,
                    Content        = card.Content,
                    ReadMoreButton = _navigationItemService.GetViewModel(card.ReadMoreButton)
                };

                if (card.Image.Image != null)
                {
                    viewModel.Image = new ImageViewModel()
                    {
                        Url             = card.Image.Image.Url,
                        AlternativeText = card.Image.Image.GetPropertyValue <string>("altText").IsNullOrWhiteSpace() ? card.Image.Image.GetPropertyValue <string>("altText") : card.Image.Image.Name,
                        TitleText       = card.Image.Image.GetPropertyValue <string>("titleText"),
                    };
                }
                ;

                viewModels.Add(viewModel);
            }

            return(viewModels);
        }
        private IEnumerable <ResourceItemViewModel> GetResourcesItems(HomePage content)
        {
            var viewModels = new List <ResourceItemViewModel>();

            if (ExistenceUtility.IsNullOrEmpty(content.ResourcesItems))
            {
                return(viewModels);
            }

            foreach (var item in content.ResourcesItems)
            {
                var viewModel = new ResourceItemViewModel()
                {
                    Content        = item.Content,
                    ReadMoreButton = _navigationItemService.GetViewModel(item.Link)
                };

                if (item.Image != null)
                {
                    viewModel.ImageUrl = item.Image.Url;
                }

                viewModels.Add(viewModel);
            }

            return(viewModels);
        }
 protected T CreateViewModel <T>(ISidebarComposition composition) where T : BasicSidebarViewModel, new()
 {
     return(new T
     {
         PrimaryCallToActionButton = _navigationItemService.GetViewModel(composition.SidebarPrimaryCallToActionButton),
         DataHubLinks = GetDataHubLinks(composition),
         SeeAlsoLinks = _navigationItemService.GetViewModels(composition.SidebarSeeAlsoLinks)
     });
 }
        public IEnumerable <SocialMediaNavigationItemViewModel> GetSocialMediaLinks(RelatedLinks relatedLinks)
        {
            var links = new List <SocialMediaNavigationItemViewModel>();

            if (relatedLinks == null)
            {
                return(links);
            }

            foreach (var relatedLink in relatedLinks)
            {
                var link = _navigationItemService.GetViewModel <SocialMediaNavigationItemViewModel>(relatedLink);
                link.IconClassSuffix = relatedLink.Caption.ToLower();

                links.Add(link);
            }

            return(links);
        }