public virtual IActionResult ProductAddPopup(int selectedOfferId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts) &&
                !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord))
            {
                return(AccessDeniedView());
            }

            var model = new AddOfferTypeModel();

            if (selectedOfferId > 0)
            {
                var product = _productService.GetProductById(selectedOfferId);
                if (product != null)
                {
                    model.SelectedOfferId = product.Id;
                    model.OfferType       = OfferType.Product;
                    model.OfferName       = product.Name;
                }
            }

            model.SelectOfferType = true;

            return(View("~/Plugins/Progressive.Web.App/Views/ProductAddPopup.cshtml", model));
        }
        public virtual IActionResult ProductAddPopupList(DataSourceRequest command, AddOfferTypeModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts) &&
                !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord))
            {
                return(AccessDeniedKendoGridJson());
            }

            var gridModel = new DataSourceResult();
            var products  = _productService.SearchProducts(
                categoryIds: new List <int> {
                model.SearchCategoryId
            },
                manufacturerId: model.SearchManufacturerId,
                storeId: model.SearchStoreId,
                vendorId: model.SearchVendorId,
                productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null,
                keywords: model.SearchProductName,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize,
                showHidden: true
                );

            gridModel.Data  = products.Select(x => x.ToModel());
            gridModel.Total = products.TotalCount;

            return(Json(gridModel));
        }
        public IActionResult CategoryAddPopupList()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories) &&
                !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord))
            {
                return(AccessDeniedView());
            }

            var model = new AddOfferTypeModel();

            model.AvailableStores.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            foreach (var s in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString()
                });
            }
            return(View("~/Plugins/Progressive.Web.App/Views/CategoryAddPopup.cshtml", model));
        }
        public virtual IActionResult CategoryAddPopupList(DataSourceRequest command, AddOfferTypeModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories) &&
                !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord))
            {
                return(AccessDeniedKendoGridJson());
            }

            var categories = _categoryService.GetAllCategories(model.SearchCategoryName,
                                                               model.SearchStoreId, command.Page - 1, command.PageSize, true);
            var gridModel = new DataSourceResult
            {
                Data = categories.Select(x =>
                {
                    var categoryModel        = x.ToModel();
                    categoryModel.Breadcrumb = x.GetFormattedBreadCrumb(_categoryService);
                    return(categoryModel);
                }),
                Total = categories.TotalCount
            };

            return(Json(gridModel));
        }
        public virtual IActionResult CategoryAddPopup(int selectedOfferId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories) &&
                !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord))
            {
                return(AccessDeniedView());
            }

            var model = new AddOfferTypeModel();

            if (selectedOfferId > 0)
            {
                var category = _categoryService.GetCategoryById(selectedOfferId);
                if (category != null)
                {
                    model.SelectedOfferId = category.Id;
                    model.OfferType       = OfferType.Category;
                    model.OfferName       = category.Name;
                }
            }

            model.SelectOfferType = true;
            return(View("~/Plugins/Progressive.Web.App/Views/CategoryAddPopup.cshtml", model));
        }
        public IActionResult ProductAddPopupList()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts) &&
                !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord))
            {
                return(AccessDeniedView());
            }

            var model = new AddOfferTypeModel();

            //categories
            model.AvailableCategories.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true);

            foreach (var c in categories)
            {
                model.AvailableCategories.Add(c);
            }

            //manufacturers
            model.AvailableManufacturers.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            var manufacturers = SelectListHelper.GetManufacturerList(_manufacturerService, _cacheManager, true);

            foreach (var m in manufacturers)
            {
                model.AvailableManufacturers.Add(m);
            }

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            foreach (var s in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString()
                });
            }

            //vendors
            model.AvailableVendors.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            var vendors = SelectListHelper.GetVendorList(_vendorService, _cacheManager, true);

            foreach (var v in vendors)
            {
                model.AvailableVendors.Add(v);
            }

            //product types
            model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList();
            model.AvailableProductTypes.Insert(0, new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });

            return(View("~/Plugins/Progressive.Web.App/Views/ProductAddPopup.cshtml", model));
        }