Beispiel #1
0
        public async Task <IActionResult> ProductUpdate(CollectionModel.CollectionProductModel model)
        {
            if (ModelState.IsValid)
            {
                await _collectionViewModelService.ProductUpdate(model);

                return(new JsonResult(""));
            }
            return(ErrorForKendoGridJson(ModelState));
        }
        public virtual async Task ProductUpdate(CollectionModel.CollectionProductModel model)
        {
            var product = await _productService.GetProductById(model.ProductId);

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

            var productCollection = product.ProductCollections.Where(x => x.Id == model.Id).FirstOrDefault();

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

            productCollection.IsFeaturedProduct = model.IsFeaturedProduct;
            productCollection.DisplayOrder      = model.DisplayOrder;

            await _productCollectionService.UpdateProductCollection(productCollection, model.ProductId);
        }