示例#1
0
        public ViewViewComponentResult Invoke(BannerWidgetProperties properties)
        {
            var imagePath = GetImagePath(properties);

            return(View("~/Components/Widgets/BannerWidget/_BannerWidget.cshtml", new BannerWidgetModel
            {
                ImagePath = imagePath,
                Text = properties.Text,
                LinkUrl = properties.LinkUrl,
                LinkTitle = properties.LinkTitle
            }));
        }
示例#2
0
        private string GetImagePath(BannerWidgetProperties properties)
        {
            var imageGuid = properties.Image.FirstOrDefault()?.FileGuid ?? Guid.Empty;

            if (imageGuid == Guid.Empty)
            {
                return(null);
            }

            var image = mediaFileProvider.Get(imageGuid, SiteContext.CurrentSiteID);

            if (image == null)
            {
                return(string.Empty);
            }

            return(fileUrlRetriever.Retrieve(image).RelativePath);
        }