public IActionResult CategoryAddPopupList(DataSourceRequest command, RequirementModel.AddCategoryModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(Content("Access denied"));
            }

            var categories = _categoryService.GetAllCategories(
                model.SearchCategoryName,
                model.SearchStoreId,
                command.Page - 1,
                command.PageSize,
                true
                );

            return(Json(GetCategoryGridModel(categories)));
        }
        private AddCategoryToDiscountListModel GetCategoryGridModel(RequirementModel.AddCategoryModel searchModel, IPagedList <Category> categories)
        {
            return(new AddCategoryToDiscountListModel().PrepareToGrid(searchModel, categories, () =>
            {
                return categories.Select(category =>
                {
                    //fill in model values from the entity
                    var categoryModel = category.ToModel <CategoryModel>();

                    //fill in additional values (not existing in the entity)
                    categoryModel.Breadcrumb = _categoryService.GetFormattedBreadCrumb(category);
                    categoryModel.SeName = _urlRecordService.GetSeName(category, 0, true, false);

                    return categoryModel;
                });
            }));
        }
        public IActionResult CategoryAddPopup()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(Content("Access denied"));
            }

            var model = new RequirementModel.AddCategoryModel();

            //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()
                });
            }

            return(View("~/Plugins/DiscountRules.HasCategories/Views/CategoryAddPopup.cshtml", model));
        }