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);
        }
        /// <summary>
        /// CREATOR: Rasha Mohammed
        /// CREATED: 3/1/2020
        /// APPROVER: Robert Holmes
        ///
        /// Update a field of the product .
        /// </summary>
        /// <remarks>
        /// UPDATED BY:
        /// UPDATED DATE:
        /// CHANGES:
        ///
        /// </remarks>
        public bool EditProduct(Product oldProduct, Product newProduct)
        {
            bool result = false;

            try
            {
                result = _productAccessor.UpdateProduct(oldProduct, newProduct) == 1;
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Update failed", ex);
            }

            return(result);
        }