示例#1
0
        /// <summary>
        /// This method inserts a 'Method' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Method' to insert.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject InsertMethod(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 Insert StoredProcedure
                InsertMethodStoredProcedure insertMethodProc = 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 insertMethodProc from MethodWriter
                        // The DataWriter converts the 'Method'
                        // to the SqlParameter[] array needed to insert a 'Method'.
                        insertMethodProc = MethodWriter.CreateInsertMethodStoredProcedure(method);
                    }

                    // Verify insertMethodProc exists
                    if (insertMethodProc != null)
                    {
                        // Execute Insert Stored Procedure
                        returnObject.IntegerValue = this.DataManager.MethodManager.InsertMethod(insertMethodProc, dataConnector);
                    }
                }
                else
                {
                    // Raise Error Data Connection Not Available
                    throw new Exception("The database connection is not available.");
                }
            }

            // return value
            return(returnObject);
        }