public IActionResult ProductUpdate(CategoryModel.CategoryProductModel model)
 {
     if (ModelState.IsValid)
     {
         _categoryViewModelService.UpdateProductCategoryModel(model);
         return(new NullJsonResult());
     }
     return(ErrorForKendoGridJson(ModelState));
 }
Пример #2
0
        public async Task <IActionResult> ProductDelete(CategoryModel.CategoryProductModel model)
        {
            if (ModelState.IsValid)
            {
                await _categoryViewModelService.DeleteProductCategoryModel(model.Id, model.ProductId);

                return(new NullJsonResult());
            }
            return(ErrorForKendoGridJson(ModelState));
        }
Пример #3
0
        public async Task <IActionResult> ProductUpdate(CategoryModel.CategoryProductModel model)
        {
            if (ModelState.IsValid)
            {
                await _categoryViewModelService.UpdateProductCategoryModel(model);

                return(new JsonResult(""));
            }
            return(ErrorForKendoGridJson(ModelState));
        }
Пример #4
0
        public ActionResult ProductUpdate(GridCommand command, CategoryModel.CategoryProductModel model)
        {
            var productCategory = _categoryService.GetProductCategoryById(model.Id);

            productCategory.IsFeaturedProduct = model.IsFeaturedProduct;
            productCategory.DisplayOrder      = model.DisplayOrder1;

            _categoryService.UpdateProductCategory(productCategory);

            return(ProductList(command, productCategory.CategoryId));
        }
Пример #5
0
        public ActionResult ProductUpdate(GridCommand command, CategoryModel.CategoryProductModel model)
        {
            var productCategory = _categoryService.GetProductCategoryById(model.Id);

            if (_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                productCategory.IsFeaturedProduct = model.IsFeaturedProduct;
                productCategory.DisplayOrder      = model.DisplayOrder1;

                _categoryService.UpdateProductCategory(productCategory);
            }

            return(ProductList(command, productCategory.CategoryId));
        }
Пример #6
0
        public ActionResult ProductList(GridCommand command, int categoryId)
        {
            var model = new GridModel <CategoryModel.CategoryProductModel>();

            if (_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                var productCategories = _categoryService.GetProductCategoriesByCategoryId(categoryId, command.Page - 1, command.PageSize, true);

                var products = _productService.GetProductsByIds(productCategories.Select(x => x.ProductId).ToArray());

                model.Data = productCategories.Select(x =>
                {
                    var productModel = new CategoryModel.CategoryProductModel
                    {
                        Id                = x.Id,
                        CategoryId        = x.CategoryId,
                        ProductId         = x.ProductId,
                        IsFeaturedProduct = x.IsFeaturedProduct,
                        DisplayOrder1     = x.DisplayOrder
                    };

                    var product = products.FirstOrDefault(y => y.Id == x.ProductId);

                    if (product != null)
                    {
                        productModel.ProductName          = product.Name;
                        productModel.Sku                  = product.Sku;
                        productModel.ProductTypeName      = product.GetProductTypeLabel(_localizationService);
                        productModel.ProductTypeLabelHint = product.ProductTypeLabelHint;
                        productModel.Published            = product.Published;
                    }

                    return(productModel);
                });

                model.Total = productCategories.TotalCount;
            }
            else
            {
                model.Data = Enumerable.Empty <CategoryModel.CategoryProductModel>();

                NotifyAccessDenied();
            }

            return(new JsonResult
            {
                Data = model
            });
        }
        public virtual ProductCategory UpdateProductCategoryModel(CategoryModel.CategoryProductModel model)
        {
            var product         = _productService.GetProductById(model.ProductId);
            var productCategory = product.ProductCategories.FirstOrDefault(x => x.Id == model.Id);

            if (productCategory == null)
            {
                throw new ArgumentException("No product category mapping found with the specified id");
            }

            productCategory.IsFeaturedProduct = model.IsFeaturedProduct;
            productCategory.DisplayOrder      = model.DisplayOrder;
            productCategory.ProductId         = model.ProductId;
            _categoryService.UpdateProductCategory(productCategory);
            return(productCategory);
        }
Пример #8
0
        public virtual ActionResult ProductUpdate(CategoryModel.CategoryProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            var productCategory = _categoryService.GetProductCategoryById(model.Id);

            if (productCategory == null)
            {
                throw new ArgumentException("No product category mapping found with the specified id");
            }

            productCategory.IsFeaturedProduct = model.IsFeaturedProduct;
            productCategory.DisplayOrder      = model.DisplayOrder;
            _categoryService.UpdateProductCategory(productCategory);

            return(new NullJsonResult());
        }
Пример #9
0
        public ActionResult ProductList(GridCommand command, int categoryId)
        {
            var model = new GridModel <CategoryModel.CategoryProductModel>();

            var productCategories = _categoryService.GetProductCategoriesByCategoryId(categoryId, command.Page - 1, command.PageSize, true);

            var products = _productService.GetProductsByIds(productCategories.Select(x => x.ProductId).ToArray());

            model.Data = productCategories.Select(x =>
            {
                var productModel = new CategoryModel.CategoryProductModel
                {
                    Id                = x.Id,
                    CategoryId        = x.CategoryId,
                    ProductId         = x.ProductId,
                    IsFeaturedProduct = x.IsFeaturedProduct,
                    DisplayOrder1     = x.DisplayOrder,
                    IsSystemMapping   = x.IsSystemMapping
                };

                var product = products.FirstOrDefault(y => y.Id == x.ProductId);

                if (product != null)
                {
                    productModel.ProductName          = product.Name;
                    productModel.Sku                  = product.Sku;
                    productModel.ProductTypeName      = product.GetProductTypeLabel(_localizationService);
                    productModel.ProductTypeLabelHint = product.ProductTypeLabelHint;
                    productModel.Published            = product.Published;
                }

                return(productModel);
            });

            model.Total = productCategories.TotalCount;

            return(new JsonResult
            {
                Data = model
            });
        }
Пример #10
0
        public virtual async Task <(IEnumerable <CategoryModel.CategoryProductModel> categoryProductModels, int totalCount)> PrepareCategoryProductModel(string categoryId, int pageIndex, int pageSize)
        {
            var productCategories = await _categoryService.GetProductCategoriesByCategoryId(categoryId,
                                                                                            pageIndex - 1, pageSize, true);

            var categoryproducts = new List <CategoryModel.CategoryProductModel>();

            foreach (var item in productCategories)
            {
                var pc = new CategoryModel.CategoryProductModel {
                    Id                = item.Id,
                    CategoryId        = item.CategoryId,
                    ProductId         = item.ProductId,
                    ProductName       = (await _productService.GetProductById(item.ProductId))?.Name,
                    IsFeaturedProduct = item.IsFeaturedProduct,
                    DisplayOrder      = item.DisplayOrder
                };
                categoryproducts.Add(pc);
            }
            return(categoryproducts, productCategories.TotalCount);
        }
Пример #11
0
        public ActionResult ProductList(GridCommand command, int categoryId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();

            var productCategories = _categoryService.GetProductCategoriesByCategoryId(categoryId, command.Page - 1, command.PageSize, true);

            var products = _productService.GetProductsByIds(productCategories.Select(x => x.ProductId).ToArray());

            var model = new GridModel<CategoryModel.CategoryProductModel>
            {
                Data = productCategories.Select(x =>
                {
                    var productModel = new CategoryModel.CategoryProductModel
                    {
                        Id = x.Id,
                        CategoryId = x.CategoryId,
                        ProductId = x.ProductId,
                        IsFeaturedProduct = x.IsFeaturedProduct,
                        DisplayOrder1 = x.DisplayOrder
                    };

                    var product = products.FirstOrDefault(y => y.Id == x.ProductId);

                    if (product != null)
                    {
                        productModel.ProductName = product.Name;
                        productModel.Sku = product.Sku;
                        productModel.ProductTypeName = product.GetProductTypeLabel(_localizationService);
                        productModel.ProductTypeLabelHint = product.ProductTypeLabelHint;
                        productModel.Published = product.Published;
                    }

                    return productModel;
                }),
                Total = productCategories.TotalCount
            };

            return new JsonResult
            {
                Data = model
            };
        }