示例#1
0
        /// <summary>
        /// This method updates a 'Method' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Method' to update.
        /// <returns>A PolymorphicObject object with a value.
        internal PolymorphicObject UpdateMethod(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            Method method = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Update StoredProcedure
                UpdateMethodStoredProcedure updateMethodProc = null;

                // verify the first parameters is a(n) 'Method'.
                if (parameters[0].ObjectValue as Method != null)
                {
                    // Create Method Parameter
                    method = (Method)parameters[0].ObjectValue;

                    // verify method exists
                    if (method != null)
                    {
                        // Now create updateMethodProc from MethodWriter
                        // The DataWriter converts the 'Method'
                        // to the SqlParameter[] array needed to update a 'Method'.
                        updateMethodProc = MethodWriter.CreateUpdateMethodStoredProcedure(method);
                    }

                    // Verify updateMethodProc exists
                    if (updateMethodProc != null)
                    {
                        // Execute Update Stored Procedure
                        bool saved = this.DataManager.MethodManager.UpdateMethod(updateMethodProc, dataConnector);

                        // Create returnObject.Boolean
                        returnObject.Boolean = new NullableBoolean();

                        // If save was successful
                        if (saved)
                        {
                            // Set returnObject.Boolean.Value to true
                            returnObject.Boolean.Value = NullableBooleanEnum.True;
                        }
                        else
                        {
                            // Set returnObject.Boolean.Value to false
                            returnObject.Boolean.Value = NullableBooleanEnum.False;
                        }
                    }
                    else
                    {
                        // Raise Error Data Connection Not Available
                        throw new Exception("The database connection is not available.");
                    }
                }
            }

            // return value
            return(returnObject);
        }