Exemple #1
0
        public ViewResult HeroSlider()
        {
            var viewModel = new HeroSliderViewModel();

            if (!String.IsNullOrEmpty(_contextWrapper.Datasource))
            {
                var contentItem = _mediaContentService.GetHeroSliderContent(_contextWrapper.Datasource);
                foreach (var slide in contentItem?.Slides)
                {
                    viewModel.HeroImages.Add(new HeroSliderImageViewModel()
                    {
                        Image = new HtmlString(_glassHtml.Editable <IHeroSliderSlide>(slide, i => i.Image))
                    });
                }
                var firstItem = viewModel.HeroImages.FirstOrDefault();
                firstItem.IsActive   = true;
                viewModel.ParentGuid = contentItem.Id.ToString();
            }

            var parameterValue = _contextWrapper.GetParameterValue("Slide Interval in Milliseconds");

            int interval = 0;

            if (int.TryParse(parameterValue, out interval))
            {
                viewModel.SlideInterval = interval;
            }

            viewModel.IsInExperienceEditorMode = _contextWrapper.IsExperienceEditor;

            return(View(viewModel));
        }
        public ViewResult HeroSlider()
        {
            var viewModel = new HeroSliderViewModel();

            if (!String.IsNullOrEmpty(RenderingContext.Current.Rendering.DataSource))
            {
                var contentItem = _mediaContentService.GetHeroSliderContent(RenderingContext.Current.Rendering.DataSource);
                foreach (var slide in contentItem?.Slides)
                {
                    viewModel.HeroImages.Add(new HeroSliderImageViewModel()
                    {
                        Id       = slide.Id.ToString(),
                        MediaUrl = slide.Image?.Src,
                        AltText  = slide.Image?.Alt
                    });
                }

                var firstItem = viewModel.HeroImages.FirstOrDefault();
                firstItem.IsActive   = true;
                viewModel.ParentGuid = contentItem.Id.ToString();
            }
            var parameterValue = _contextWrapper.GetParameterValue("Slide Interval in Milliseconds");

            int interval = 0;

            if (int.TryParse(parameterValue, out interval))
            {
                viewModel.SlideInterval = interval;
            }

            viewModel.IsInExperienceEditorMode = _contextWrapper.IsExperienceEditor;
            return(View(viewModel));
        }