public CampaignTilesViewModel BuildModel()
        {
            var model = new CampaignTilesViewModel();

            var tileImages     = BuildImages("TileImages_Content");
            var tileNavigation = _relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(_umbracoContent, "TileNavigation_Content");

            var total = tileImages.Count > tileNavigation.Count ? tileImages.Count : tileNavigation.Count;

            for (var i = 0; i < total; i++)
            {
                var image       = (i < tileImages.Count) ? tileImages[i] : null;
                var title       = (i < tileNavigation.Count) ? tileNavigation[i].Text : null;
                var url         = (i < tileNavigation.Count) ? tileNavigation[i].Url : null;
                var description = (i < 12) ? _umbracoContent.GetPropertyValue <string>($"Tile{i+1}Description_Content") : null;

                model.Tiles.Add(new CampaignTile()
                {
                    Image       = image,
                    Title       = title,
                    Url         = url,
                    Description = description
                });
            }

            model.BannerImageSmall = BuildImage("BannerImageSmall_Design");
            model.BannerImageLarge = BuildImage("BannerImageLarge_Design");

            model.TileFontFamily             = _umbracoContent.GetPropertyValue <string>("TileFontFamily_Design");
            model.TileTitleTextColour        = _umbracoContent.GetPropertyValue <string>("TileTitleColour_Design");
            model.TileDescriptionsTextColour = _umbracoContent.GetPropertyValue <string>("TileDescriptionColour_Design");

            model.CustomCssSmallScreen  = new HtmlString(_umbracoContent.GetPropertyValue <string>("CssSmall_Design"));
            model.CustomCssMediumScreen = new HtmlString(_umbracoContent.GetPropertyValue <string>("CssMedium_Design"));
            model.CustomCssLargeScreen  = new HtmlString(_umbracoContent.GetPropertyValue <string>("CssLarge_Design"));

            // Add sibling pages
            foreach (var sibling in _umbracoContent.Siblings <IPublishedContent>())
            {
                model.CampaignPages.Add(new GuideNavigationLink()
                {
                    Text          = sibling.Name,
                    Url           = new Uri(sibling.Url, UriKind.Relative),
                    IsCurrentPage = (sibling.Id == _umbracoContent.Id)
                });
            }


            return(model);
        }
        /// <summary>
        /// For each related link, create a <see cref="LandingSectionViewModel" />
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="relatedLinksService">The related links service.</param>
        /// <returns></returns>
        private static IList <LandingSectionViewModel> BuildLandingLinksViewModelFromUmbracoContent(IPublishedContent content, IRelatedLinksService relatedLinksService)
        {
            var sections = new List <LandingSectionViewModel>()
            {
            };
            var relatedLinks = relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(content, "LandingNavigation_Content");

            foreach (var link in relatedLinks)
            {
                var section = new LandingSectionViewModel()
                {
                    Heading = link,
                    Links   = new HtmlLink[0]
                };
                sections.Add(section);
            }
            return(sections);
        }
Beispiel #3
0
        /// <summary>
        /// For each Umbraco Related Links property that has some data, create a <see cref="LandingSectionViewModel" /> with a heading link and list of child links.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="relatedLinksService">The related links service.</param>
        /// <returns></returns>
        private static IList <LandingSectionViewModel> BuildLandingLinksViewModelFromUmbracoContent(IPublishedContent content, IRelatedLinksService relatedLinksService)
        {
            var sections = new List <LandingSectionViewModel>();

            for (var i = 1; i <= 15; i++)
            {
                var relatedLinks = relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(content, "links" + i + "_Content");
                if (relatedLinks.Count > 0)
                {
                    var section = new LandingSectionViewModel()
                    {
                        Links = relatedLinks
                    };

                    section.Heading = section.Links[0];
                    section.Links.RemoveAt(0);

                    sections.Add(section);
                }
            }
            return(sections);
        }
        public CampaignLandingViewModel BuildModel()
        {
            var model = new CampaignLandingViewModel();

            model.HeadingColour      = _umbracoContent.GetPropertyValue <string>("HeadingColour_Design");
            model.Introduction       = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_umbracoContent.GetPropertyValue <string>("Introduction_Content")));
            model.IntroductionColour = _umbracoContent.GetPropertyValue <string>("IntroductionColour_Design");

            model.LandingNavigation.Sections        = BuildLandingLinksViewModelFromUmbracoContent(_umbracoContent, _relatedLinksService);
            model.LandingNavigationBackgroundColour = _umbracoContent.GetPropertyValue <string>("LandingNavigationBackgroundColour_Design");
            model.LandingNavigationTextColour       = _umbracoContent.GetPropertyValue <string>("LandingNavigationTextColour_Design");

            var buttonLinks = _relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(_umbracoContent, "ButtonNavigation_Content");

            for (var i = 0; i <= 2 && i < buttonLinks.Count; i++)
            {
                var target = buttonLinks[i];
                if (target != null)
                {
                    model.ButtonTargets.Add(target);
                    model.ButtonDescriptions.Add(_umbracoContent.GetPropertyValue <string>("Button" + (i + 1) + "Description_Content"));
                }
            }

            model.ButtonsTopMarginSmall  = _umbracoContent.GetPropertyValue <int?>("ButtonsTopMarginSmall_Design");
            model.ButtonsTopMarginMedium = _umbracoContent.GetPropertyValue <int?>("ButtonsTopMarginMedium_Design");
            model.ButtonsTopMarginLarge  = _umbracoContent.GetPropertyValue <int?>("ButtonsTopMarginLarge_Design");

            model.Button1BackgroundColour = _umbracoContent.GetPropertyValue <string>("Button1BackgroundColour_Design");
            model.Button1TextColour       = _umbracoContent.GetPropertyValue <string>("Button1TextColour_Design");
            model.Button2BackgroundColour = _umbracoContent.GetPropertyValue <string>("Button2BackgroundColour_Design");
            model.Button2TextColour       = _umbracoContent.GetPropertyValue <string>("Button2TextColour_Design");
            model.Button3BackgroundColour = _umbracoContent.GetPropertyValue <string>("Button3BackgroundColour_Design");
            model.Button3TextColour       = _umbracoContent.GetPropertyValue <string>("Button3TextColour_Design");

            model.Content       = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_umbracoContent.GetPropertyValue <string>("Content_Content")));
            model.ContentColour = _umbracoContent.GetPropertyValue <string>("ContentColour_Design");

            var imageData = _umbracoContent.GetPropertyValue <IPublishedContent>("BackgroundSmall_Design");

            if (imageData != null)
            {
                model.BackgroundImageSmall = new Image()
                {
                    ImageUrl = _mediaUrlTransformer.TransformMediaUrl(new Uri(imageData.Url, UriKind.Relative))
                };
            }
            imageData = _umbracoContent.GetPropertyValue <IPublishedContent>("BackgroundMedium_Design");
            if (imageData != null)
            {
                model.BackgroundImageMedium = new Image()
                {
                    ImageUrl = _mediaUrlTransformer.TransformMediaUrl(new Uri(imageData.Url, UriKind.Relative))
                };
            }
            imageData = _umbracoContent.GetPropertyValue <IPublishedContent>("BackgroundLarge_Design");
            if (imageData != null)
            {
                model.BackgroundImageLarge = new Image()
                {
                    ImageUrl = _mediaUrlTransformer.TransformMediaUrl(new Uri(imageData.Url, UriKind.Relative))
                };
            }
            model.BackgroundColour = _umbracoContent.GetPropertyValue <string>("BackgroundColour_Design");
            model.BackgroundImageWrapsHorizontally = _umbracoContent.GetPropertyValue <bool>("BackgroundImageWrapsHorizontally_Design");
            model.BackgroundImageWrapsVertically   = _umbracoContent.GetPropertyValue <bool>("BackgroundImageWrapsVertically_Design");

            model.AlignIntroductionMedium      = _umbracoContent.GetPropertyValue <string>("AlignIntroductionMedium_Design");
            model.AlignIntroductionLarge       = _umbracoContent.GetPropertyValue <string>("AlignIntroductionLarge_Design");
            model.AlignLandingNavigationMedium = _umbracoContent.GetPropertyValue <string>("AlignLandingNavigationMedium_Design");
            model.AlignLandingNavigationLarge  = _umbracoContent.GetPropertyValue <string>("AlignLandingNavigationLarge_Design");
            model.AlignButtonsMedium           = _umbracoContent.GetPropertyValue <string>("AlignButtonsMedium_Design");
            model.AlignButtonsLarge            = _umbracoContent.GetPropertyValue <string>("AlignButtonsLarge_Design");

            model.CustomCssSmallScreen  = new HtmlString(_umbracoContent.GetPropertyValue <string>("CssSmall_Design"));
            model.CustomCssMediumScreen = new HtmlString(_umbracoContent.GetPropertyValue <string>("CssMedium_Design"));
            model.CustomCssLargeScreen  = new HtmlString(_umbracoContent.GetPropertyValue <string>("CssLarge_Design"));

            model.VideoHeight = _umbracoContent.GetPropertyValue <int?>("VideoHeight_Design");

            model.ShareStyle = _umbracoContent.GetPropertyValue <string>("ShareStyle_Design");

            model.GoogleAdWordsTag = _umbracoContent.GetPropertyValue <string>("GoogleAdWordsTag");

            return(model);
        }
        private PersonViewModel MapUmbracoContentToViewModel(IPublishedContent content, ILatestService latestService, ISocialMediaService socialMediaService, IEastSussex1SpaceService eastSussex1SpaceService, IWebChatSettingsService webChatSettingsService, IRelatedLinksService relatedLinksService, IContentExperimentSettingsService contentExperimentSettingsService, IEscisService escisService, IMediaUrlTransformer mediaUrlTransformer)
        {
            var model = new PersonViewModel
            {
                JobTitle    = content.GetPropertyValue <string>("jobTitle_Content"),
                LeadingText = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("leadingText_Content"))),
                Subheading1 = content.GetPropertyValue <string>("subheading1_Content"),
                Content1    = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("content1_Content"))),
                Subheading2 = content.GetPropertyValue <string>("subheading2_Content"),
                Content2    = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("content2_Content"))),
                Contact     = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("contact_Content")))
            };

            model.Metadata.PersonAbout.Name.Titles.Add(content.GetPropertyValue <string>("HonorificTitle_Content"));
            model.Metadata.PersonAbout.Name.GivenNames.Add(content.GetPropertyValue <string>("GivenName_Content"));
            model.Metadata.PersonAbout.Name.FamilyName = content.GetPropertyValue <string>("FamilyName_Content");
            model.Metadata.PersonAbout.Name.Suffixes.Add(content.GetPropertyValue <string>("HonorificSuffix_Content"));
            model.Metadata.PersonAbout.EmailAddresses.Add(content.GetPropertyValue <string>("email_Content"));
            model.Metadata.PersonAbout.TelephoneNumbers.Add(content.GetPropertyValue <string>("phone_Content"));
            model.Metadata.Person = model.Metadata.PersonAbout.Name.ToString();
            if (!String.IsNullOrEmpty(model.JobTitle))
            {
                model.Metadata.Person += ", " + model.JobTitle;
            }

            var relatedLinksGroups = new RelatedLinksModelBuilder().OrganiseAsHeadingsAndSections(relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(content, "relatedLinks_Content"));

            foreach (var linkGroup in relatedLinksGroups)
            {
                model.RelatedLinksGroups.Add(linkGroup);
            }

            var imageData = content.GetPropertyValue <IPublishedContent>("photo_Content");

            if (imageData != null)
            {
                model.Photo = new Image()
                {
                    AlternativeText = imageData.Name,
                    ImageUrl        = new Uri(imageData.Url, UriKind.Relative),
                    Width           = imageData.GetPropertyValue <int>("umbracoWidth"),
                    Height          = imageData.GetPropertyValue <int>("umbracoHeight")
                };
                model.Metadata.PageImageUrl = new Uri(Request.Url, model.Photo.ImageUrl).ToString();
            }

            // Add common properties to the model
            var modelBuilder = new BaseViewModelBuilder();

            modelBuilder.PopulateBaseViewModel(model, content, contentExperimentSettingsService, UmbracoContext.Current.InPreviewMode);
            modelBuilder.PopulateBaseViewModelWithInheritedContent(model, latestService, socialMediaService, eastSussex1SpaceService, webChatSettingsService, escisService);

            return(model);
        }
Beispiel #6
0
        /// <summary>
        /// Maps the Umbraco content to the view model.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="expiryDate">The expiry date.</param>
        /// <param name="latestService">The latest service.</param>
        /// <param name="socialMediaService">The social media service.</param>
        /// <param name="eastSussex1SpaceService">The East Sussex One Space service.</param>
        /// <param name="webChatSettingsService">The web chat settings service.</param>
        /// <param name="relatedLinksService">The related links service.</param>
        /// <param name="contentExperimentSettingsService">The content experiment settings service.</param>
        /// <param name="escisService">The escis service.</param>
        /// <param name="ratingSettings">The rating settings.</param>
        /// <param name="mediaUrlTransformer">The media URL transformer.</param>
        /// <param name="skinService">The skin service.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">content
        /// or
        /// latestService
        /// or
        /// socialMediaService
        /// or
        /// eastSussex1SpaceService
        /// or
        /// webChatSettingsService
        /// or
        /// relatedLinksService</exception>
        /// <exception cref="System.ArgumentNullException">content
        /// or
        /// latestService
        /// or
        /// socialMediaService
        /// or
        /// eastSussex1SpaceService
        /// or
        /// webChatSettingsService
        /// or
        /// relatedLinksService
        /// or
        /// contentExperimentSettingsService</exception>
        /// <remarks>
        /// Method is virtual so that document types which inherit from the 'Location' type can also inherit and extend the controller
        /// </remarks>
        protected virtual async Task <LocationViewModel> MapUmbracoContentToViewModel(IPublishedContent content, DateTime?expiryDate, latest.ILatestService latestService, ISocialMediaService socialMediaService, IEastSussex1SpaceService eastSussex1SpaceService, IWebChatSettingsService webChatSettingsService, IRelatedLinksService relatedLinksService, IContentExperimentSettingsService contentExperimentSettingsService, IEscisService escisService, IRatingSettingsProvider ratingSettings, IMediaUrlTransformer mediaUrlTransformer, ISkinToApplyService skinService)
        {
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            if (latestService == null)
            {
                throw new ArgumentNullException("latestService");
            }
            if (socialMediaService == null)
            {
                throw new ArgumentNullException("socialMediaService");
            }
            if (eastSussex1SpaceService == null)
            {
                throw new ArgumentNullException("eastSussex1SpaceService");
            }
            if (webChatSettingsService == null)
            {
                throw new ArgumentNullException("webChatSettingsService");
            }
            if (relatedLinksService == null)
            {
                throw new ArgumentNullException("relatedLinksService");
            }
            if (contentExperimentSettingsService == null)
            {
                throw new ArgumentNullException("contentExperimentSettingsService");
            }
            if (ratingSettings == null)
            {
                throw new ArgumentNullException(nameof(ratingSettings));
            }
            if (skinService == null)
            {
                throw new ArgumentNullException(nameof(skinService));
            }

            var model = new LocationViewModel
            {
                Content             = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("content_Content"))),
                OpeningHoursDetails = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("openingHoursDetails_Content"))),
                Tab1Title           = content.GetPropertyValue <string>("tab1title_Content"),
                Tab1Content         = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("tab1content_Content"))),
                Tab2Title           = content.GetPropertyValue <string>("tab2title_Content"),
                Tab2Content         = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("tab2content_Content"))),
                Tab3Title           = content.GetPropertyValue <string>("tab3title_Content"),
                Tab3Content         = new HtmlString(mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(content.GetPropertyValue <string>("tab3content_Content"))),
                Location            = content.GetPropertyValue <AddressInfo>("location_Content"),
                Email1Label         = content.GetPropertyValue <string>("email1label_Content"),
                Email2Label         = content.GetPropertyValue <string>("email2label_Content"),
                Email1      = content.GetPropertyValue <string>("email1_Content"),
                Email2      = content.GetPropertyValue <string>("email2_Content"),
                Phone1Label = content.GetPropertyValue <string>("phone1label_Content"),
                Phone2Label = content.GetPropertyValue <string>("phone2label_Content"),
                Phone1      = content.GetPropertyValue <string>("phone1_Content"),
                Phone2      = content.GetPropertyValue <string>("phone2_Content"),
                Fax1Label   = content.GetPropertyValue <string>("fax1label_Content"),
                Fax2Label   = content.GetPropertyValue <string>("fax2label_Content"),
                Fax1        = content.GetPropertyValue <string>("fax1_Content"),
                Fax2        = content.GetPropertyValue <string>("fax2_Content")
            };

            var relatedLinksGroups = new RelatedLinksModelBuilder().OrganiseAsHeadingsAndSections(relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(content, "relatedLinks_Content"));

            foreach (var linkGroup in relatedLinksGroups)
            {
                model.RelatedLinksGroups.Add(linkGroup);
            }

            // Opening times
            model.OpeningHours = DeserialiseOpeningHours(content);
            WorkOutRelativeOpeningTimes(model);
            WorkOutNextOpenRelativeTime(model);

            // Photo
            var imageData = content.GetPropertyValue <IPublishedContent>("photo_Content");

            if (imageData != null)
            {
                model.Photo = new Image()
                {
                    AlternativeText = imageData.Name,
                    ImageUrl        = new Uri(imageData.Url, UriKind.Relative),
                    Width           = imageData.GetPropertyValue <int>("umbracoWidth"),
                    Height          = imageData.GetPropertyValue <int>("umbracoHeight")
                };
                model.Metadata.PageImageUrl = new Uri(Request.Url, model.Photo.ImageUrl).ToString();
            }

            // Add common properties to the model
            var modelBuilder = new BaseViewModelBuilder(new EastSussexGovUKTemplateRequest(Request, webChatSettingsService: webChatSettingsService));
            await modelBuilder.PopulateBaseViewModel(model, content, contentExperimentSettingsService,
                                                     expiryDate,
                                                     UmbracoContext.Current.InPreviewMode, skinService);

            modelBuilder.PopulateBaseViewModelWithInheritedContent(model, latestService, socialMediaService, eastSussex1SpaceService, escisService, ratingSettings);

            return(model);
        }
        /// <summary>
        /// Gets the view model.
        /// </summary>
        /// <returns></returns>
        public GuideStepViewModel BuildModel()
        {
            var model = new GuideStepViewModel()
            {
                GuideUrl    = new Uri(_content.Parent.Url, UriKind.RelativeOrAbsolute),
                GuideTitle  = _content.Parent.Name,
                StepContent = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_content.GetPropertyValue <string>("content_Content")))
            };

            model.Metadata.IsPartOfUrl = _content.Parent.UrlAbsolute();
            model.Metadata.IsInSearch  = !_content.GetPropertyValue <bool>("hideFromSearchEngines");

            var sectionNavigation = _content.Parent.GetPropertyValue <int>("SectionNavigation_Navigation");

            model.StepsHaveAnOrder = (sectionNavigation == 0 || umbraco.library.GetPreValueAsString(sectionNavigation).ToUpperInvariant() != "BULLETED LIST");

            var relatedLinksGroups = new RelatedLinksModelBuilder().OrganiseAsHeadingsAndSections(_relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(_content, "relatedLinks_Content"));

            foreach (var linkGroup in relatedLinksGroups)
            {
                model.RelatedLinksGroups.Add(linkGroup);
            }

            model.Steps = new List <GuideNavigationLink>(_content.Siblings <IPublishedContent>()
                                                         .Where(sibling => sibling.ContentType == _content.ContentType)
                                                         .Select(sibling => new GuideNavigationLink()
            {
                Text          = sibling.Name,
                Url           = new Uri(sibling.Url, UriKind.Relative),
                IsCurrentPage = (sibling.Id == _content.Id)
            }));


            var partnerImages = _content.GetPropertyValue <IEnumerable <IPublishedContent> >("partnerImages_Content");

            foreach (var imageData in partnerImages)
            {
                var image = new Image()
                {
                    AlternativeText = imageData.Name,
                    ImageUrl        = new Uri(imageData.Url, UriKind.Relative),
                    Width           = imageData.GetPropertyValue <int>("umbracoWidth"),
                    Height          = imageData.GetPropertyValue <int>("umbracoHeight")
                };
                model.PartnerImages.Add(image);
            }

            return(model);
        }
        /// <summary>
        /// Maps the Umbraco content to a <see cref="LocationViewModel"/>
        /// </summary>
        /// <returns></returns>
        public LocationViewModel BuildModel()
        {
            var model = new LocationViewModel
            {
                Content             = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_content.GetPropertyValue <string>("content_Content"))),
                OpeningHoursDetails = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_content.GetPropertyValue <string>("openingHoursDetails_Content"))),
                Tab1Title           = _content.GetPropertyValue <string>("tab1title_Content"),
                Tab1Content         = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_content.GetPropertyValue <string>("tab1content_Content"))),
                Tab2Title           = _content.GetPropertyValue <string>("tab2title_Content"),
                Tab2Content         = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_content.GetPropertyValue <string>("tab2content_Content"))),
                Tab3Title           = _content.GetPropertyValue <string>("tab3title_Content"),
                Tab3Content         = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_content.GetPropertyValue <string>("tab3content_Content"))),
                Location            = _content.GetPropertyValue <AddressInfo>("location_Content"),
                Email1Label         = _content.GetPropertyValue <string>("email1label_Content"),
                Email2Label         = _content.GetPropertyValue <string>("email2label_Content"),
                Email1           = _content.GetPropertyValue <string>("email1_Content"),
                Email2           = _content.GetPropertyValue <string>("email2_Content"),
                ContactFormUrl   = string.IsNullOrEmpty(_content.GetPropertyValue <string>("contactFormURL")) ? null : new Uri(_content.GetPropertyValue <string>("contactFormURL"), UriKind.RelativeOrAbsolute),
                ContactFormLabel = _content.GetPropertyValue <string>("contactFormLabel"),
                Phone1Label      = _content.GetPropertyValue <string>("phone1label_Content"),
                Phone2Label      = _content.GetPropertyValue <string>("phone2label_Content"),
                Phone1           = _content.GetPropertyValue <string>("phone1_Content"),
                Phone2           = _content.GetPropertyValue <string>("phone2_Content"),
                Fax1Label        = _content.GetPropertyValue <string>("fax1label_Content"),
                Fax2Label        = _content.GetPropertyValue <string>("fax2label_Content"),
                Fax1             = _content.GetPropertyValue <string>("fax1_Content"),
                Fax2             = _content.GetPropertyValue <string>("fax2_Content")
            };

            var relatedLinksGroups = new RelatedLinksModelBuilder().OrganiseAsHeadingsAndSections(_relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(_content, "relatedLinks_Content"));

            foreach (var linkGroup in relatedLinksGroups)
            {
                model.RelatedLinksGroups.Add(linkGroup);
            }

            // Opening times
            model.OpeningHours = DeserialiseOpeningHours(_content);
            WorkOutRelativeOpeningTimes(model);
            WorkOutNextOpenRelativeTime(model);

            // Photo
            var imageData = _content.GetPropertyValue <IPublishedContent>("photo_Content");

            if (imageData != null)
            {
                model.Photo = new Image()
                {
                    AlternativeText = imageData.Name,
                    ImageUrl        = new Uri(imageData.Url, UriKind.Relative),
                    Width           = imageData.GetPropertyValue <int>("umbracoWidth"),
                    Height          = imageData.GetPropertyValue <int>("umbracoHeight")
                };
                model.Metadata.PageImage.ImageUrl        = new Uri(new Uri(_content.UrlWithDomain()), model.Photo.ImageUrl);
                model.Metadata.PageImage.AlternativeText = model.Photo.AlternativeText;
            }

            return(model);
        }
        /// <summary>
        /// Builds the model.
        /// </summary>
        /// <returns></returns>
        public TaskViewModel BuildModel()
        {
            var model = new TaskViewModel
            {
                LeadingText     = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_umbracoContent.GetPropertyValue <string>("leadingText_Content"))),
                StartPageUrl    = _elibraryLinkConverter.RewriteElibraryUrl(_mediaUrlTransformer.TransformUrl(new Uri(_umbracoContent.GetPropertyValue <string>("startPageUrl_Content"), UriKind.RelativeOrAbsolute))),
                StartButtonText = _umbracoContent.GetPropertyValue <string>("startButtonText_Content"),
                Subheading1     = _umbracoContent.GetPropertyValue <string>("subheading1_Content"),
                Content1        = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_umbracoContent.GetPropertyValue <string>("content1_Content"))),
                Subheading2     = _umbracoContent.GetPropertyValue <string>("subheading2_Content"),
                Content2        = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_umbracoContent.GetPropertyValue <string>("content2_Content"))),
                Subheading3     = _umbracoContent.GetPropertyValue <string>("subheading3_Content"),
                Content3        = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_umbracoContent.GetPropertyValue <string>("content3_Content"))),
                Subheading4     = _umbracoContent.GetPropertyValue <string>("subheading4_Content"),
                Content4        = new HtmlString(_mediaUrlTransformer.ParseAndTransformMediaUrlsInHtml(_umbracoContent.GetPropertyValue <string>("content4_Content")))
            };

            var relatedLinksGroups = new RelatedLinksModelBuilder().OrganiseAsHeadingsAndSections(_relatedLinksService.BuildRelatedLinksViewModelFromUmbracoContent(_umbracoContent, "relatedLinks_Content"));

            foreach (var linkGroup in relatedLinksGroups)
            {
                model.RelatedLinksGroups.Add(linkGroup);
            }

            var partnerImages = _umbracoContent.GetPropertyValue <IEnumerable <IPublishedContent> >("partnerImages_Content");

            foreach (var imageData in partnerImages)
            {
                var image = new Image()
                {
                    AlternativeText = imageData.Name,
                    ImageUrl        = _mediaUrlTransformer.TransformUrl(new Uri(imageData.Url, UriKind.Relative)),
                    Width           = imageData.GetPropertyValue <int>("umbracoWidth"),
                    Height          = imageData.GetPropertyValue <int>("umbracoHeight")
                };
                model.PartnerImages.Add(image);
            }

            return(model);
        }