Exemple #1
0
        public virtual ProductItem Save(ProductItem productItem)
        {
            if (productItem == null)
            {
                throw new ArgumentException("ProductItem cannot be null");
            }

            Product product = null;

            if (productItem.Id == 0)
            {
                product = productItem.CreateProduct();
            }
            else
            {
                product = this.productManager.Get(productItem.Id);
                productItem.UpdateProduct(product);
            }

            var productInDB         = this.productManager.Save(product);
            var productItemToReturn = ProductItem.FromModel(productInDB);

            return(productItemToReturn);
        }