コード例 #1
0
        //edit
        public ActionResult EditPopup(int id)
        {
            var sbw = _bannerService.GetById(id);

            if (sbw == null)
            {
                //No record found with the specified id
                return(RedirectToAction("Configure"));
            }

            var model = new BannerInfoModel()
            {
                Id           = sbw.Id,
                StoreId      = sbw.StoreId,
                BannerHtml   = sbw.BannerHtml,
                CategoryId   = sbw.CategoryId,
                WidgetzoneId = sbw.WidgetzoneId
            };

            var selectedStore = _storeService.GetStoreById(sbw.StoreId);

            //stores
            model.AvailableStores.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });
            foreach (var store in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem()
                {
                    Text = store.Name, Value = store.Id.ToString(), Selected = (selectedStore != null && store.Id == selectedStore.Id)
                });
            }

            var selectedCategory = _categoryService.GetCategoryById(sbw.CategoryId);

            model.AvailableCategories.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });
            foreach (var category in _categoryService.GetAllCategories())
            {
                model.AvailableCategories.Add(new SelectListItem()
                {
                    Text = category.Name, Value = category.Id.ToString(), Selected = (selectedCategory != null && category.Id == selectedCategory.Id)
                });
            }

            var selectedPlacement = _bannerService.GetBannerWidgetzoneById(sbw.WidgetzoneId);

            foreach (var placement in _bannerService.GetAllBannerWidgetzones())
            {
                model.AvailableWidgetZones.Add(new SelectListItem()
                {
                    Text = placement.WidgetZone, Value = placement.Id.ToString(), Selected = (selectedCategory != null && placement.Id == selectedPlacement.Id)
                });
            }

            return(View("~/Plugins/Widgets.IkBanner/Views/WidgetsBanner/EditPopup.cshtml", model));
        }
コード例 #2
0
        public ActionResult BannerList(DataSourceRequest command)
        {
            var records  = _bannerService.GetAll(command.Page - 1, command.PageSize);
            var sbwModel = records.Select(x =>
            {
                var m = new BannerInfoModel()
                {
                    Id           = x.Id,
                    StoreId      = x.StoreId,
                    CategoryId   = x.CategoryId,
                    WidgetzoneId = x.WidgetzoneId,
                    BannerHtml   = x.BannerHtml,
                };
                //store
                var store       = _storeService.GetStoreById(x.StoreId);
                m.StoreName     = (store != null) ? store.Name : "*";
                var category    = _categoryService.GetCategoryById(x.CategoryId);
                m.CategoryName  = (category != null) ? category.Name : "*";
                var WidgetZones = _bannerService.GetBannerWidgetzoneById(x.WidgetzoneId);
                m.WidgetZone    = (WidgetZones != null) ? WidgetZones.WidgetZone : "";
                return(m);
            })
                           .ToList();
            var gridModel = new DataSourceResult
            {
                Data  = sbwModel,
                Total = records.Count
            };

            return(Json(gridModel));
        }
コード例 #3
0
        public ActionResult BannerInfo(string widgetZone, int?categoryId)
        {
            var model            = new BannerModel();
            var bannerWidgetzone = _bannerService.GetBannerWidgetzoneByZone(widgetZone);

            if (bannerWidgetzone == null)
            {
                return(View("~/Plugins/Widgets.IkBanner/Views/WidgetsBanner/BannerInfo.cshtml", model));
            }
            model.IsStatic = bannerWidgetzone.IsStatic;
            var banners = _bannerService.GetAllByWidgetzone(bannerWidgetzone.Id, categoryId.HasValue ? categoryId.Value : 0);

            foreach (var banner in banners)
            {
                if (banner.StoreId == 0 || banner.StoreId == _storeContext.CurrentStore.Id)
                {
                    var bim = new BannerInfoModel();
                    bim.Id           = banner.Id;
                    bim.BannerHtml   = banner.BannerHtml;
                    bim.StoreId      = banner.StoreId;
                    bim.CategoryId   = banner.CategoryId;
                    bim.WidgetzoneId = banner.WidgetzoneId;
                    model.AvailableBanners.Add(bim);
                }
            }
            return(View("~/Plugins/Widgets.IkBanner/Views/WidgetsBanner/BannerInfo.cshtml", model));
        }
コード例 #4
0
        public ActionResult AddPopup(string btnId, string formId, BannerInfoModel model)
        {
            var bannerRecord = new IkBanner.Domain.IkBanner();

            bannerRecord.BannerHtml   = model.BannerHtml;
            bannerRecord.StoreId      = model.StoreId;
            bannerRecord.CategoryId   = model.CategoryId;
            bannerRecord.WidgetzoneId = model.WidgetzoneId;
            _bannerService.InsertBanner(bannerRecord);

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

            return(View("~/Plugins/Widgets.IkBanner/Views/WidgetsBanner/AddPopup.cshtml", model));
        }
コード例 #5
0
        public ActionResult EditPopup(string btnId, string formId, BannerInfoModel model)
        {
            var sbw = _bannerService.GetById(model.Id);

            if (sbw == null)
            {
                //No record found with the specified id
                return(RedirectToAction("Configure"));
            }

            sbw.StoreId      = model.StoreId;
            sbw.BannerHtml   = model.BannerHtml;
            sbw.CategoryId   = model.CategoryId;
            sbw.WidgetzoneId = model.WidgetzoneId;
            _bannerService.UpdateBanner(sbw);

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

            return(View("~/Plugins/Widgets.IkBanner/Views/WidgetsBanner/EditPopup.cshtml", model));
        }
コード例 #6
0
        //add
        public ActionResult AddPopup()
        {
            var model = new BannerInfoModel();

            model.AvailableStores.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });
            foreach (var store in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem()
                {
                    Text = store.Name, Value = store.Id.ToString()
                });
            }

            model.AvailableCategories.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });
            foreach (var category in _categoryService.GetAllCategories())
            {
                model.AvailableCategories.Add(new SelectListItem()
                {
                    Text = category.Name, Value = category.Id.ToString()
                });
            }

            foreach (var placement in _bannerService.GetAllBannerWidgetzones())
            {
                model.AvailableWidgetZones.Add(new SelectListItem()
                {
                    Text = placement.WidgetZone, Value = placement.Id.ToString()
                });
            }

            return(View("~/Plugins/Widgets.IkBanner/Views/WidgetsBanner/AddPopup.cshtml", model));
        }
コード例 #7
0
        public ActionResult Configure()
        {
            var model = new BannerInfoModel();

            return(View("~/Plugins/Widgets.IkBanner/Views/WidgetsBanner/Configure.cshtml", model));
        }