Ejemplo n.º 1
0
        /// <summary author="Jared Greenfield" created="2019/02/09">
        /// Updates an Item with a new Item.
        /// </summary>
        /// <param name="oldItem">The old Item.</param>
        /// <param name="newItem">The updated Item.</param>
        /// <exception cref="SQLException">Insert Fails (example of exception tag)</exception>
        /// <returns>True if the update was successful, false if not.</returns>
        public bool UpdateItem(Item oldItem, Item newItem)
        {
            bool result = false;

            try
            {
                if (oldItem.IsValid())
                {
                    if (newItem.IsValid())
                    {
                        if (1 == _itemAccessor.UpdateItem(oldItem, newItem))
                        {
                            result = true;
                        }
                    }
                    else
                    {
                        throw new ArgumentException("The new Item is not valid.");
                    }
                }
                else
                {
                    throw new ArgumentException("The old Item is not valid.");
                }
            }
            catch (Exception ex)
            {
                ExceptionLogManager.getInstance().LogException(ex);
                throw ex;
            }
            return(result);
        }