public ActionResult UpdateAttribute(ProductAttributeModel model) { var entity = model.MapTo <ProductAttribute>(); _attributeService.UpdateProductAttribute(entity); var stock = GetProductStockQuantity(model.ProductId); var product = _productService.GetProductById(model.ProductId); product.StockQuantity = stock; if (product.Price != 0 && model.Price > 0) { product.Price = product.Price < model.Price ? product.Price : model.Price; } else { product.Price = model.Price; } _productService.UpdateProduct(product); var jsonData = new { attributeId = entity.Id, stock = stock, price = product.Price }; return(AbpJson(jsonData)); }
public ActionResult CreateAttribute(ProductAttributeModel model) { var entity = model.MapTo <ProductAttribute>(); var attributeId = _attributeService.InsertProductAttribute(entity); var stock = GetProductStockQuantity(model.ProductId); var product = _productService.GetProductById(model.ProductId); product.StockQuantity = stock; product.Price = product.Price < model.Price ? product.Price : model.Price; _productService.UpdateProduct(product); var jsonData = new { attributeId = attributeId, stock = stock }; return(AbpJson(jsonData)); }
public static ProductAttribute ToEntity(this ProductAttributeModel model, ProductAttribute destination) { return(model.MapTo(destination)); }
public static ProductAttribute ToEntity(this ProductAttributeModel model) { return(model.MapTo <ProductAttributeModel, ProductAttribute>()); }