Ejemplo n.º 1
0
        public bool UpdateProduct(Product oldProduct, Product newProduct)
        {
            bool result = false;

            try
            {
                result = (1 == _productAccessor.UpdateProduct(oldProduct, newProduct));
                if (result == false)
                {
                    throw new ApplicationException("Product data not changed.");
                }

                if (oldProduct.Active != newProduct.Active)
                {
                    if (newProduct.Active == true)
                    {
                        _productAccessor.ReactivateProduct(oldProduct.ProductID);
                    }
                    else
                    {
                        _productAccessor.DeactivateProduct(oldProduct.ProductID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Update Failed.", ex);
            }

            return(result);
        }