示例#1
0
        // Returns the relative path to the first attachment selected via the page attachment selector component
        private string GetAttachmentUrl(IEnumerable <AttachmentSelectorItem> attachments)
        {
            Guid attachmentGuid = attachments.FirstOrDefault()?.FileGuid ?? Guid.Empty;

            DocumentAttachment attachment = DocumentHelper.GetAttachment(attachmentGuid, siteService.CurrentSite.SiteName);

            return(attachmentUrlRetriever.Retrieve(attachment).RelativePath);
        }
 public static SocialLinkViewModel GetViewModel(SocialLink link, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new SocialLinkViewModel
     {
         Url = link.Fields.Url,
         Title = link.Fields.Title,
         IconPath = attachmentUrlRetriever.Retrieve(link.Fields.Icon).RelativePath
     });
 }
示例#3
0
 public static CafeViewModel GetViewModel(Cafe cafe, CountryRepository countryRepository, IStringLocalizer <SharedResources> localizer, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new CafeViewModel
     {
         PhotoPath = cafe.Fields.Photo == null ? null : attachmentUrlRetriever.Retrieve(cafe.Fields.Photo).RelativePath,
         Note = cafe.Fields.AdditionalNotes,
         Contact = ContactViewModel.GetViewModel(cafe, countryRepository, localizer)
     });
 }
 public static AboutUsSectionViewModel GetViewModel(AboutUsSection aboutUsSection, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new AboutUsSectionViewModel
     {
         Heading = aboutUsSection.Fields.Heading,
         Text = aboutUsSection.Fields.Text,
         ImagePath = aboutUsSection.Fields.Image == null ? null : attachmentUrlRetriever.Retrieve(aboutUsSection.Fields.Image).RelativePath
     });
 }
示例#5
0
 /// <summary>
 /// Gets ViewModel for <paramref name="cafe"/>.
 /// </summary>
 /// <param name="cafe">Cafe.</param>
 /// <param name="attachmentUrlRetriever">Attachment URL retriever.</param>
 /// <returns>Hydrated view model.</returns>
 public static CafeCardViewModel GetViewModel(Cafe cafe, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(cafe == null
         ? new CafeCardViewModel()
         : new CafeCardViewModel
     {
         Name = cafe.Fields.Name,
         PhotoPath = cafe.Fields.Photo == null ? null : attachmentUrlRetriever.Retrieve(cafe.Fields.Photo).RelativePath
     });
 }
 public static ArticleViewModel GetViewModel(Article article, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new ArticleViewModel
     {
         PublicationDate = article.PublicationDate,
         RelatedArticles = article.Fields.RelatedArticles.OfType <Article>().Select(relatedArticle => RelatedArticleViewModel.GetViewModel(relatedArticle, true, pageUrlRetriever, attachmentUrlRetriever)),
         TeaserPath = article.Fields.Teaser == null ? null : attachmentUrlRetriever.Retrieve(article.Fields.Teaser).RelativePath,
         Text = article.Fields.Text,
         Title = article.Fields.Title
     });
 }
 public static RelatedArticleViewModel GetViewModel(Article article, bool handleArticlePosition, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new RelatedArticleViewModel
     {
         Summary = article.Fields.Summary,
         TeaserPath = article.Fields.Teaser == null ? null : attachmentUrlRetriever.Retrieve(article.Fields.Teaser).WithSizeConstraint(SizeConstraint.Height(301)).RelativePath,
         Title = article.Fields.Title,
         PublicationDate = article.PublicationDate,
         HandleArticlePosition = handleArticlePosition,
         Url = pageUrlRetriever.Retrieve(article).RelativePath
     });
 }
        public ActionResult Index()
        {
            var properties = propertiesRetriever.Retrieve <ImageWidgetProperties>();
            var image      = GetImage(properties);

            outputCacheDependencies.AddDependencyOnPageAttachmnent(image?.AttachmentGUID ?? Guid.Empty);

            return(PartialView("Widgets/_ImageWidget", new ImageWidgetViewModel
            {
                ImagePath = image == null ? null : attachmentUrlRetriever.Retrieve(image).RelativePath
            }));
        }
 public static ArticleWithSideBarViewModel GetViewModel(Article article, ArticleWithSideBarProperties templateProperties, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new ArticleWithSideBarViewModel
     {
         TeaserPath = article.Fields.Teaser == null ? null : attachmentUrlRetriever.Retrieve(article.Fields.Teaser).RelativePath,
         PublicationDate = article.PublicationDate,
         RelatedArticles = article.Fields.RelatedArticles.OfType <Article>().Select(relatedArticle => RelatedArticleViewModel.GetViewModel(relatedArticle, false, pageUrlRetriever, attachmentUrlRetriever)),
         Text = article.Fields.Text,
         Title = article.Fields.Title,
         SidebarLocation = (ArticleSidebarLocationEnum)Enum.Parse(typeof(ArticleSidebarLocationEnum), templateProperties.SidebarLocation, true),
         ArticleWidth = templateProperties.ArticleWidth,
     });
 }
示例#10
0
 public static ArticleViewModel GetViewModel(Article article, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new ArticleViewModel
     {
         PublicationDate = article.PublicationDate,
         RelatedArticles = article.Fields.RelatedArticles.OfType <Article>().Select(related => GetViewModel(related, pageUrlRetriever, attachmentUrlRetriever)),
         Summary = article.Fields.Summary,
         TeaserUrl = article.Fields.Teaser == null ? null : attachmentUrlRetriever.Retrieve(article.Fields.Teaser),
         Text = article.Fields.Text,
         Title = article.Fields.Title,
         Url = pageUrlRetriever.Retrieve(article).RelativePath
     });
 }
示例#11
0
        public static HomeSectionViewModel GetViewModel(HomeSection homeSection, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever)
        {
            var link = homeSection?.Fields.Link.FirstOrDefault();

            return(homeSection == null ? null : new HomeSectionViewModel
            {
                BackgroundImagePath = attachmentUrlRetriever.Retrieve(homeSection.Fields.Image).RelativePath,
                Heading = homeSection.Fields.Heading,
                Text = homeSection.Fields.Text,
                MoreButtonText = homeSection.Fields.LinkText,
                MoreButtonUrl = link != null?pageUrlRetriever.Retrieve(link).RelativePath : string.Empty
            });
        }
示例#12
0
 public static ArticleViewModel GetViewModel(Article article, IPageUrlRetriever pageUrlRetriever, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new ArticleViewModel
     {
         PublicationDate = article.PublicationDate,
         RelatedArticles = article.Fields.RelatedArticles.OfType <Article>().Select(relatedArticle => GetViewModel(relatedArticle, pageUrlRetriever, attachmentUrlRetriever)) ?? Enumerable.Empty <ArticleViewModel>(),
         Summary = article.Fields.Summary,
         TeaserUrl = article.Fields.Teaser == null ? null : attachmentUrlRetriever.Retrieve(article.Fields.Teaser),
         BynderTeaserUrl = !string.IsNullOrEmpty(article.Fields.TeaserWithBynder) ? JObject.Parse(article.Fields.TeaserWithBynder)["assetUrl"].ToString() : null,
         Text = article.Fields.Text,
         Title = article.Fields.Title,
         Url = pageUrlRetriever.Retrieve(article).RelativePath
     });
 }
示例#13
0
        public static ReferenceViewModel GetViewModel(Reference reference, IPageAttachmentUrlRetriever attachmentUrlRetriever)
        {
            if (reference == null)
            {
                return(null);
            }

            return(new ReferenceViewModel
            {
                Name = reference.ReferenceName,
                Description = reference.ReferenceDescription,
                Text = reference.ReferenceText,
                ImagePath = attachmentUrlRetriever.Retrieve(reference.Fields.Image).RelativePath
            });
        }
示例#14
0
        public ActionResult Index()
        {
            // Retrieves the GUID of the first selected attachment from the 'Attachments' property
            Guid guid = propertiesRetriever.Retrieve <CustomWidgetProperties>().Attachments.FirstOrDefault()?.FileGuid ?? Guid.Empty;
            // Retrieves the DocumentAttachment object that corresponds to the selected attachment GUID
            DocumentAttachment attachment = DocumentHelper.GetAttachment(guid, siteService.CurrentSite.SiteID);

            string url = String.Empty;

            if (attachment != null)
            {
                // Retrieves the relative URL of the selected attachment
                url = attachmentUrlRetriever.Retrieve(attachment).RelativePath;
            }

            // Custom logic...

            return(View());
        }
示例#15
0
        public async Task <string> GetAttachmentImageAsync(TreeNode Page, Guid ImageGuid)
        {
            var Attachment = Page?.AllAttachments.Where(x => x.AttachmentGUID == ImageGuid).FirstOrDefault();

            return(Attachment != null ? _pageAttachmentUrlRetriever.Retrieve(Attachment).RelativePath : "");
        }