Esempio n. 1
0
        /// <summary>
        /// This method deletes a 'Address' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Address' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject DeleteAddress(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Delete StoredProcedure
                DeleteAddressStoredProcedure deleteAddressProc = null;

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

                    // verify address exists
                    if (address != null)
                    {
                        // Now create deleteAddressProc from AddressWriter
                        // The DataWriter converts the 'Address'
                        // to the SqlParameter[] array needed to delete a 'Address'.
                        deleteAddressProc = AddressWriter.CreateDeleteAddressStoredProcedure(address);
                    }
                }

                // Verify deleteAddressProc exists
                if (deleteAddressProc != null)
                {
                    // Execute Delete Stored Procedure
                    bool deleted = this.DataManager.AddressManager.DeleteAddress(deleteAddressProc, dataConnector);

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

                    // If delete was successful
                    if (deleted)
                    {
                        // 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);
        }
        /// <summary>
        /// This method creates an instance of an
        /// 'DeleteAddress'StoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Address_Delete'.
        /// </summary>
        /// <param name="address">The 'Address' to Delete.</param>
        /// <returns>An instance of a 'DeleteAddressStoredProcedure' object.</returns>
        public static DeleteAddressStoredProcedure CreateDeleteAddressStoredProcedure(Address address)
        {
            // Initial Value
            DeleteAddressStoredProcedure deleteAddressStoredProcedure = new DeleteAddressStoredProcedure();

            // Now Create Parameters For The DeleteProc
            deleteAddressStoredProcedure.Parameters = CreatePrimaryKeyParameter(address);

            // return value
            return(deleteAddressStoredProcedure);
        }
        /// <summary>
        /// This method deletes a 'Address' object.
        /// </summary>
        /// <returns>True if successful false if not.</returns>
        /// </summary>
        public bool DeleteAddress(DeleteAddressStoredProcedure deleteAddressProc, DataConnector databaseConnector)
        {
            // Initial Value
            bool deleted = false;

            // Verify database connection is connected
            if ((databaseConnector != null) && (databaseConnector.Connected))
            {
                // Execute Non Query
                deleted = this.DataHelper.DeleteRecord(deleteAddressProc, databaseConnector);
            }

            // return value
            return(deleted);
        }