Esempio n. 1
0
        public ActionResult Configure(SliderItemModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }
            var item = _sliderItemService.GetMailPageSlides().Where(x => x.Id == model.Id).FirstOrDefault();

            if (item.PictureId != model.PictureId)
            {
                if (item.PictureId != 0)
                {
                    var pic = _pictureService.GetPictureById(item.PictureId);
                    if (pic != null)
                    {
                        _pictureService.DeletePicture(pic);
                    }
                }
                item.PictureId = model.PictureId;
            }

            foreach (var lang in _languageService.GetAllLanguages())
            {
                var locale = model.Locales.Where(x => x.LanguageId == lang.Id).FirstOrDefault();
                _localizedEntityService.SaveLocalizedValue(item, x => x.TitleText, locale.Text, lang.Id);
                _localizedEntityService.SaveLocalizedValue(item, x => x.ShortText, locale.SubText, lang.Id);
            }


            item.Url = model.Link;
            _sliderItemService.Update(item);
            var newModel = new SliderItemListModel();

            newModel.Slides = new List <SliderItemModel>();
            var items = _sliderItemService.GetMailPageSlides();

            foreach (var newItem in items)
            {
                var tmpModel = new SliderItemModel();
                tmpModel.Locales   = new List <SliderItemLocalizedModel>();
                tmpModel.Id        = newItem.Id;
                tmpModel.PictureId = newItem.PictureId;
                tmpModel.Link      = newItem.Url;
                AddLocales(_languageService, tmpModel.Locales, (locale, languageId) =>
                {
                    locale.SubText = newItem.GetLocalized(x => x.ShortText, languageId, false, false);
                    locale.Text    = newItem.GetLocalized(x => x.TitleText, languageId, false, false);
                });
                newModel.Slides.Add(tmpModel);
            }
            newModel.Returning = true;
            return(View("Nop.Plugin.Widgets.NivoSlider.Views.WidgetsNivoSlider.Configure", newModel));
        }
Esempio n. 2
0
        public ActionResult Configure()
        {
            var model = new SliderItemListModel();

            model.Slides = new List <SliderItemModel>();
            var items = _sliderItemService.GetMailPageSlides();

            foreach (var item in items)
            {
                var tmpModel = new SliderItemModel();
                tmpModel.Locales   = new List <SliderItemLocalizedModel>();
                tmpModel.Id        = item.Id;
                tmpModel.PictureId = item.PictureId;
                tmpModel.Link      = item.Url;
                AddLocales(_languageService, tmpModel.Locales, (locale, languageId) =>
                {
                    locale.SubText = item.GetLocalized(x => x.ShortText, languageId, false, false);
                    locale.Text    = item.GetLocalized(x => x.TitleText, languageId, false, false);
                });
                model.Slides.Add(tmpModel);
            }
            //var model = new ConfigurationModel();
            //model.Picture1Id = _nivoSliderSettings.Picture1Id;
            //model.Text1 = _nivoSliderSettings.Text1;
            //model.SubText1 = _nivoSliderSettings.SubText1;
            //model.Link1 = _nivoSliderSettings.Link1;

            //model.Picture2Id = _nivoSliderSettings.Picture2Id;
            //model.Text2 = _nivoSliderSettings.Text2;
            //model.SubText2 = _nivoSliderSettings.SubText2;
            //model.Link2 = _nivoSliderSettings.Link2;

            //model.Picture3Id = _nivoSliderSettings.Picture3Id;
            //model.Text3 = _nivoSliderSettings.Text3;
            //model.SubText3 = _nivoSliderSettings.SubText3;
            //model.Link3 = _nivoSliderSettings.Link3;

            //model.Picture4Id = _nivoSliderSettings.Picture4Id;
            //model.Text4 = _nivoSliderSettings.Text4;
            //model.SubText4 = _nivoSliderSettings.SubText4;
            //model.Link4 = _nivoSliderSettings.Link4;

            return(View("Nop.Plugin.Widgets.NivoSlider.Views.WidgetsNivoSlider.Configure", model));
        }
Esempio n. 3
0
        public ActionResult PublicInfo(string widgetZone)
        {
            var model = new List <SliderItemModel>();
            var items = _sliderItemService.GetMailPageSlides();

            foreach (var item in items)
            {
                if (item.PictureId == 0)
                {
                    continue;
                }
                var tmpModel = new SliderItemModel();
                tmpModel.PictureUrl = _pictureService.GetPictureUrl(item.PictureId, showDefaultPicture: false);
                tmpModel.Text       = "<strong><a href=\"" + item.Url + "\" >" + item.GetLocalized(x => x.TitleText, _workContext.WorkingLanguage.Id, false) + "</a></strong><div>" + item.GetLocalized(x => x.ShortText, _workContext.WorkingLanguage.Id, false) + "</div>";
                tmpModel.SubText    = item.Url;
                model.Add(tmpModel);
            }
            return(View("Nop.Plugin.Widgets.NivoSlider.Views.WidgetsNivoSlider.PublicInfo", model));
        }
Esempio n. 4
0
        /// <summary>
        /// Get the home page slider
        /// </summary>
        /// <returns></returns>
        public ActionResult GetHomeSlider()
        {
            // create the default model to return
            var model = new SliderItemModel(CurrentPage);

            //check if we have the slider parent page
            if (_slidersParentPage?.Id > 0)
            {
                //get he slider items pages
                var sliderItemPages = _slidersParentPage.Descendants("sliderItem").
                                      Where(page => page.IsPublished() &&
                                            page.HasProperty("sliderImage") &&
                                            page.HasValue("sliderImage"))
                                      .ToList();
                //if we have some slider items, then add them to the model
                if (sliderItemPages.Any())
                {
                    foreach (var sliderItem in sliderItemPages)
                    {
                        //create the new slider item
                        var slider = new SliderItem();

                        //set the default slider heading
                        var sliderHeading = sliderItem.Name;
                        //check if we have the slider heading set
                        if (sliderItem.HasProperty("sliderHeading") && sliderItem.HasValue("sliderHeading"))
                        {
                            // set the slider heading to override the default
                            sliderHeading = sliderItem.GetProperty("sliderHeading").Value().ToString();
                        }
                        //add the heading
                        slider.SliderHeading = sliderHeading;

                        //check if we have the slider text set
                        if (sliderItem.HasProperty("sliderText") && sliderItem.HasValue("sliderText"))
                        {
                            // set the slider heading to override the default
                            slider.SliderText = sliderItem.GetProperty("sliderText").Value().ToString();
                        }

                        //set slider image
                        var sliderImage = sliderItem.Value <IPublishedContent>("sliderImage");
                        if (sliderImage?.Id > 0)
                        {
                            var defaultCropSize = sliderImage.GetCropUrl("product");
                            var sliderImageUrl  = !string.IsNullOrEmpty(defaultCropSize) ?
                                                  defaultCropSize :
                                                  sliderImage.GetCropUrl(1000, 670);
                            if (!string.IsNullOrWhiteSpace(sliderImageUrl))
                            {
                                slider.SliderImage = sliderImageUrl;
                            }
                        }

                        //set slider link page and url
                        var sliderLinkPage = sliderItem.Value <IPublishedContent>("sliderLinkPage");
                        if (sliderLinkPage?.Id > 0)
                        {
                            slider.SliderLinkPage = sliderLinkPage;
                            slider.SliderUrl      = sliderLinkPage.Url;
                        }

                        //add the slider item to the list
                        model.SliderItems.Add(slider);
                    }
                }
            }

            //return the view with the model
            return(View("/Views/Partials/Global/ProductsSlider.cshtml", model));
        }