示例#1
0
        public IViewComponentResult Invoke(WidgetInstanceViewModel widgetInstance)
        {
            if (widgetInstance == null)
            {
                throw new ArgumentNullException(nameof(widgetInstance));
            }

            var model = new CarouselWidgetViewComponentVm
            {
                Id    = widgetInstance.Id,
                Items = JsonConvert.DeserializeObject <IList <CarouselWidgetViewComponentItemVm> >(widgetInstance.Data)
            };

            foreach (var item in model.Items)
            {
                item.Image = _mediaService.GetMediaUrl(item.Image);

                if (!string.IsNullOrWhiteSpace(item.Caption))
                {
                    item.Caption = _localizer.GetString(item.Caption);
                }
                if (!string.IsNullOrWhiteSpace(item.SubCaption))
                {
                    item.SubCaption = _localizer.GetString(item.SubCaption);
                }
                if (!string.IsNullOrWhiteSpace(item.LinkText))
                {
                    item.LinkText = _localizer.GetString(item.LinkText);
                }
            }

            return(View(this.GetViewPath(), model));
        }
示例#2
0
        public IViewComponentResult Invoke(WidgetInstanceViewModel widgetInstance)
        {
            var model = new CarouselWidgetViewComponentVm
            {
                Id    = widgetInstance.Id,
                Items = JsonConvert.DeserializeObject <IList <CarouselWidgetViewComponentItemVm> >(widgetInstance.Data)
            };

            foreach (var item in model.Items)
            {
                item.Image = _mediaService.GetMediaUrl(item.Image);
            }

            return(View(this.GetViewPath(), model));
        }
示例#3
0
        public IViewComponentResult Invoke(WidgetInstanceViewModel widgetInstance)
        {
            var model = new CarouselWidgetViewComponentVm
            {
                Id    = widgetInstance.Id,
                Items = JsonConvert.DeserializeObject <IList <CarouselWidgetViewComponentItemVm> >(widgetInstance.Data)
            };

            foreach (var item in model.Items)
            {
                item.Image = _mediaService.GetMediaUrl(item.Image);
            }

            return(View("/Modules/SimplCommerce.Module.Cms/Views/Components/CarouselWidget.cshtml", model));
        }
        public IViewComponentResult Invoke(WidgetInstanceVm widgetInstance)
        {
            var model = new CarouselWidgetViewComponentVm
            {
                Id = widgetInstance.Id,
                Items = JsonConvert.DeserializeObject<IList<CarouselWidgetViewComponentItemVm>>(widgetInstance.Data)
            };

            foreach(var item in model.Items)
            {
                item.Image = _mediaService.GetMediaUrl(item.Image);
            }

            return View(model);
        }