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 })); }
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); }