コード例 #1
0
        public virtual IActionResult Create(SlideModel model, bool continueEditing)
        {
            //redirect customer on accessdenied view, if client has no permissions
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }

            //return on slide creation page if model invalid
            if (!ModelState.IsValid)
            {
                //prepare model mappings
                _slideModelFactory.PrepareAclModel(model, null, true);
                _slideModelFactory.PrepareStoreMapping(model, null);

                return(View("~/Plugins/Widgets.qBoSlider/Views/Admin/Slide/Create.cshtml", model));
            }

            var slide = new Slide()
            {
                Description      = model.Description,
                HyperlinkAddress = model.Hyperlink,
                PictureId        = model.PictureId,
                StartDateUtc     = model.StartDateUtc,
                EndDateUtc       = model.EndDateUtc,
                Published        = model.Published,
                LimitedToStores  = model.SelectedStoreIds.Any(),
                SubjectToAcl     = model.SelectedCustomerRoleIds.Any()
            };

            _slideService.InsertSlide(slide);

            //update slide locales
            UpdateSlideLocales(slide, model);

            //process slide store mappings
            UpdateStoreMapping(slide, model);

            //ACL (customer roles)
            //Set catalogsettings.ignoreacl = True to use ALC
            SaveCustomerRolesAcl(slide, model);

            //ACL
            _slideModelFactory.PrepareAclModel(model, null, true);

            //store mappings
            _slideModelFactory.PrepareStoreMapping(model, null);

            //notify admin
            _notificationService.SuccessNotification(_localizationService.GetResource("Nop.Plugin.Baroque.Widgets.qBoSlider.Admin.Slide.CreatedSuccessfully"));

            //redirect on widget zone list page if customer don't want's to contiu editing
            if (!continueEditing)
            {
                return(RedirectToAction("List"));
            }

            return(RedirectToAction("Edit", new { id = slide.Id }));
        }
コード例 #2
0
        public IActionResult CreateSlidePopup(SlideModel model, string btnId, string formId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }

            var validator        = new SlideValidator(_localizationService);
            var validationResult = validator.Validate(model);

            if (validationResult.IsValid)
            {
                var slide = new Slide()
                {
                    Description      = model.Description,
                    HyperlinkAddress = model.Hyperlink,
                    PictureId        = model.PictureId,
                    DisplayOrder     = model.DisplayOrder,
                    StartDateUtc     = model.StartDateUtc,
                    EndDateUtc       = model.EndDateUtc,
                    Published        = model.Published,
                    LimitedToStores  = model.SelectedStoreIds.Any(),
                    //1.0.5 all with Alc
                    SubjectToAcl = model.SelectedCustomerRoleIds.Count > 0
                };
                _slideService.InsertSlide(slide);

                //update slide locales
                UpdateSlideLocales(slide, model);

                //process slide store mappings
                UpdateStoreMapping(slide, model);

                //ACL (customer roles)
                //Set catalogsettings.ignoreacl = True to use ALC
                SaveCustomerRolesAcl(slide, model);

                ViewBag.btnId       = btnId;
                ViewBag.formId      = formId;
                ViewBag.RefreshPage = true;
            }

            //ACL
            PrepareAclModel(model, null, true);

            //store mapping
            PrepareStoreMapping(null, model);
            return(View("~/Plugins/Widgets.qBoSlider/Views/Admin/CreateSlidePopup.cshtml", model));
        }
コード例 #3
0
 public ActionResult Create(SlideModel model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(View(model));
         }
         var currentUser = Session[Values.USER_SESSION] as UserModel;
         model.CreatedBy       = currentUser.Id;
         model.CreatedDateTime = DateTime.Now;
         _slideService.InsertSlide(model);
         SuccessNotification("Add new slider successfully.");
         return(model.ContinueEditing ? RedirectToAction("Edit", new { id = model.Id }) : RedirectToAction("List"));
     }
     catch (Exception e)
     {
         ErrorNotification("Add new slider failed");
         return(View(model));
     }
 }
コード例 #4
0
        /// <summary>
        /// Install plugin
        /// </summary>
        public override void Install()
        {
            //settings
            var settings = new qBoSliderSettings
            {
            };

            _settingService.SaveSetting(settings);

            var widgetZone = new WidgetZone()
            {
                AutoPlay                         = true,
                AutoPlayInterval                 = 3000,
                SlideDuration                    = 500,
                MinDragOffsetToSlide             = 20,
                MinSlideWidgetZoneWidth          = 200,
                MaxSlideWidgetZoneWidth          = 1920,
                SlideSpacing                     = 0,
                BulletNavigationDisplayingTypeId = 2,
                ArrowNavigationDisplayingTypeId  = 1,
                Name       = "Main homepage slider",
                SystemName = "home_page_top",
                Published  = true
            };

            _widgetZoneService.InsertWidgetZone(widgetZone);

            //install simple data
            //get sample pictures path
            var sampleImagesPath = CommonHelper.DefaultFileProvider.MapPath("~/Plugins/Widgets.qBoSlider/Content/sample-images/");

            var picture1 = _pictureService.InsertPicture(File.ReadAllBytes(string.Format("{0}banner1.jpg", sampleImagesPath)), "image/pjpeg", "qboslide-1").Id;
            var slide1   = new Slide()
            {
                Description = "<div style='color: #111; margin-top: 5%; margin-left: 5%; font-size: 16pt; font-family: arial,helvetica,sans-serif;'>" +
                              "<p style='margin: 0px;'><span style='font-family: tahoma,arial,helvetica,sans-serif;'><strong>NEW COMFORT MOUSE<br /></strong></span></p>" +
                              "<p style='margin-top: 10px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>CHOOSE FROM HUNDREDS<br /></strong></span></p>" +
                              "<p style='margin-top: 5px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>OF MODELS</strong></span></p>" +
                              "<p style='margin-top: 25px; color: #44b4f4; font-weight: bold;'><span style='font-size: 15pt; font-family: tahoma,arial,helvetica,sans-serif;'>FROM ONLY $59.00</span></p>" +
                              "<p style='margin-top: 10px;'><span style='font-size: 10pt; padding: 5px 10px; background: none repeat scroll 0% 0% #44b4f4; color: #ffffff; border-radius: 5px; font-family: tahoma,arial,helvetica,sans-serif;'><strong>SHOP NOW</strong></span></p></div>",
                PictureId = picture1,
                Published = true
            };

            _slideService.InsertSlide(slide1);

            var picture2 = _pictureService.InsertPicture(File.ReadAllBytes(string.Format("{0}banner2.jpg", sampleImagesPath)), "image/pjpeg", "qboslide-2").Id;
            var slide2   = new Slide()
            {
                Description = "<div style='color: #111; margin-top: 5%; margin-left: 5%; font-size: 16pt; font-family: arial,helvetica,sans-serif;'>" +
                              "<p style='margin: 0px;'><span style='font-family: tahoma,arial,helvetica,sans-serif;'><strong>HD PRO WEBCAM H320<br /></strong></span></p>" +
                              "<p style='margin-top: 10px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>720P FOR TRUE HD-QUALITY<br />VIDEO CHAT<br /></strong></span></p>" +
                              "<p style='margin-top: 25px; color: #44b4f4; font-weight: bold;'><span style='font-size: 15pt; font-family: tahoma,arial,helvetica,sans-serif;'>ONLY $79.00</span></p>" +
                              "<p style='margin-top: 10px;'><span style='font-size: 10pt; padding: 5px 10px; background: none repeat scroll 0% 0% #44b4f4; color: #ffffff; border-radius: 5px; font-family: tahoma,arial,helvetica,sans-serif;'><strong>SHOP NOW</strong></span></p></div>",
                PictureId = picture2,
                Published = true,
            };

            _slideService.InsertSlide(slide2);

            var picture3 = _pictureService.InsertPicture(File.ReadAllBytes(string.Format("{0}banner3.jpg", sampleImagesPath)), "image/pjpeg", "qboslide-3").Id;
            var slide3   = new Slide()
            {
                Description = "<div style='color: #111; margin-top: 5%; margin-left: 5%; font-size: 16pt; font-family: arial,helvetica,sans-serif;'>" +
                              "<p style='margin: 0px;'><span style='font-family: tahoma,arial,helvetica,sans-serif;'><strong>COMPACT CAMERA SP120</strong></span></p>" +
                              "<p style='margin-top: 10px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>20X WIDE ZOOM, 2.5 LCD, </strong></span></p>" +
                              "<p style='margin-top: 5px; margin-bottom: 0px;'><span style='font-size: 12pt; font-family: tahoma,arial,helvetica,sans-serif;'><strong>720P HD VIDEO</strong></span></p>" +
                              "<p style='margin-top: 25px; color: #44b4f4; font-weight: bold;'><span style='font-size: 15pt; font-family: tahoma,arial,helvetica,sans-serif;'>ONLY $159.00</span></p>" +
                              "<p style='margin-top: 10px;'><span style='font-size: 10pt; padding: 5px 10px; background: none repeat scroll 0% 0% #44b4f4; color: #ffffff; border-radius: 5px; font-family: tahoma,arial,helvetica,sans-serif;'><strong>SHOP NOW</strong></span></p>" +
                              "</div>",
                PictureId = picture3,
                Published = true
            };

            _slideService.InsertSlide(slide3);

            _widgetZoneSlideService.InsertWidgetZoneSlide(new WidgetZoneSlide()
            {
                SlideId      = slide1.Id,
                WidgetZoneId = widgetZone.Id,
                DisplayOrder = 0
            });

            _widgetZoneSlideService.InsertWidgetZoneSlide(new WidgetZoneSlide()
            {
                SlideId      = slide2.Id,
                WidgetZoneId = widgetZone.Id,
                DisplayOrder = 5
            });

            _widgetZoneSlideService.InsertWidgetZoneSlide(new WidgetZoneSlide()
            {
                SlideId      = slide3.Id,
                WidgetZoneId = widgetZone.Id,
                DisplayOrder = 10
            });

            base.Install();
        }