コード例 #1
0
        public virtual IActionResult ProductAddPopupList(AddProductToCategorySearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }

            ProductAttribute productAttribute = _productPictureModifierService.
                                                GetProductAttributeByName(ProductPictureModifierDefault.ProductAttributeName).First();

            IPagedList <Product> products = _productPictureModifierService.SearchProducts(
                searchModel.SearchProductName,
                searchModel.SearchCategoryId,
                productAttribute.Id,
                searchModel.Page - 1,
                searchModel.PageSize);

            var model = new DataSourceResult
            {
                Data  = products.Select(product => product.ToModel <ProductModel>()),
                Total = products.TotalCount
            };

            return(Json(model));
        }
コード例 #2
0
        public virtual IActionResult ProductAddPopupList(AddProductToCategorySearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedKendoGridJson());
            }

            //prepare model
            var model = _categoryModelFactory.PrepareAddProductToCategoryListModel(searchModel);

            return(Json(model));
        }
コード例 #3
0
        public virtual async Task <IActionResult> ProductAddPopupList(AddProductToCategorySearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCategories))
            {
                return(await AccessDeniedDataTablesJson());
            }

            //prepare model
            var model = await _categoryModelFactory.PrepareAddProductToCategoryListModelAsync(searchModel);

            return(Json(model));
        }
コード例 #4
0
        public virtual IActionResult ProductAddPopup()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }

            //prepare model
            AddProductToCategorySearchModel model = _categoryModelFactory.
                                                    PrepareAddProductToCategorySearchModel(new AddProductToCategorySearchModel());

            return(View("~/Plugins/Widgets.ProductPictureModifier/Views/Admin/ProductAddPopup.cshtml", model));
        }
コード例 #5
0
        /// <summary>
        /// Prepare paged product list model to add to the category
        /// </summary>
        /// <param name="searchModel">Product search model to add to the category</param>
        /// <returns>Product list model to add to the category</returns>
        public virtual AddProductToCategoryListModel PrepareAddProductToCategoryListModel(AddProductToCategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

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

            //prepare grid model
            var model = new AddProductToCategoryListModel
            {
                //fill in model values from the entity
                Data  = products.Select(product => product.ToModel <ProductModel>()),
                Total = products.TotalCount
            };

            return(model);
        }
コード例 #6
0
        /// <summary>
        /// Prepare product search model to add to the category
        /// </summary>
        /// <param name="searchModel">Product search model to add to the category</param>
        /// <returns>Product search model to add to the category</returns>
        public virtual AddProductToCategorySearchModel PrepareAddProductToCategorySearchModel(AddProductToCategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare available categories
            _baseAdminModelFactory.PrepareCategories(searchModel.AvailableCategories);

            //prepare available manufacturers
            _baseAdminModelFactory.PrepareManufacturers(searchModel.AvailableManufacturers);

            //prepare available stores
            _baseAdminModelFactory.PrepareStores(searchModel.AvailableStores);

            //prepare available vendors
            _baseAdminModelFactory.PrepareVendors(searchModel.AvailableVendors);

            //prepare available product types
            _baseAdminModelFactory.PrepareProductTypes(searchModel.AvailableProductTypes);

            //prepare page parameters
            searchModel.SetPopupGridPageSize();

            return(searchModel);
        }
コード例 #7
0
        /// <summary>
        /// Prepare paged product list model to add to the category
        /// </summary>
        /// <param name="searchModel">Product search model to add to the category</param>
        /// <returns>Product list model to add to the category</returns>
        public virtual AddProductToCategoryListModel PrepareAddProductToCategoryListModel(AddProductToCategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

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

            //prepare grid model
            var model = new AddProductToCategoryListModel().PrepareToGrid(searchModel, products, () =>
            {
                return(products.Select(product =>
                {
                    var productModel = product.ToModel <ProductModel>();
                    productModel.SeName = _urlRecordService.GetSeName(product, 0, true, false);

                    return productModel;
                }));
            });

            return(model);
        }