/// <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); }
private Image BuildImage(string propertyAlias) { var imageData = _umbracoContent.GetPropertyValue <IPublishedContent>(propertyAlias); if (imageData != null) { return(new Image() { ImageUrl = _mediaUrlTransformer.TransformUrl(new Uri(imageData.Url, UriKind.Relative)), AlternativeText = imageData.Name, Width = imageData.GetPropertyValue <int>("umbracoWidth"), Height = imageData.GetPropertyValue <int>("umbracoHeight") }); } return(null); }
public CampaignLandingViewModel BuildModel() { var model = new CampaignLandingViewModel(); model.BreadcrumbColour = _umbracoContent.GetPropertyValue <string>("BreadcrumbColour_Design"); 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.TransformUrl(new Uri(imageData.Url, UriKind.Relative)) }; } imageData = _umbracoContent.GetPropertyValue <IPublishedContent>("BackgroundMedium_Design"); if (imageData != null) { model.BackgroundImageMedium = new Image() { ImageUrl = _mediaUrlTransformer.TransformUrl(new Uri(imageData.Url, UriKind.Relative)) }; } imageData = _umbracoContent.GetPropertyValue <IPublishedContent>("BackgroundLarge_Design"); if (imageData != null) { model.BackgroundImageLarge = new Image() { ImageUrl = _mediaUrlTransformer.TransformUrl(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); }