public ActionResult Index()
        {
            var properties = componentPropertiesRetriever.Retrieve <CardWidgetProperties>();
            var image      = GetImage(properties);

            outputCacheDependencies.AddDependencyOnInfoObject <MediaFileInfo>(image?.FileGUID ?? Guid.Empty);

            return(PartialView("Widgets/_CardWidget", new CardWidgetViewModel
            {
                ImagePath = image == null ? null : mediaFileUrlRetriever.Retrieve(image).RelativePath,
                Text = properties.Text
            }));
        }
        public ActionResult Index()
        {
            var properties = GetProperties();
            var image      = GetImage(properties);

            outputCacheDependencies.AddDependencyOnInfoObject <MediaFileInfo>(image?.FileGUID ?? Guid.Empty);

            return(PartialView("Widgets/_CardWidget", new CardWidgetViewModel
            {
                Image = image,
                Text = properties.Text
            }));
        }
Пример #3
0
        private MediaFileInfo GetImage(BannerWidgetProperties properties)
        {
            var imageGuid = properties.Image?.FirstOrDefault()?.FileGuid ?? Guid.Empty;

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

            outputCacheDependencies.AddDependencyOnInfoObject <MediaFileInfo>(imageGuid);

            return(mediaFileRepository.GetMediaFile(imageGuid, SiteContext.CurrentSiteName));
        }
Пример #4
0
        private string GetImagePath(BannerWidgetProperties properties)
        {
            var imageGuid = properties.Image.FirstOrDefault()?.FileGuid ?? Guid.Empty;

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

            outputCacheDependencies.AddDependencyOnInfoObject <MediaFileInfo>(imageGuid);

            var image = mediaFileRepository.GetMediaFile(imageGuid, SiteContext.CurrentSiteID);

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

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