Пример #1
0
        /// <summary>
        /// This method deletes a 'ZipCode' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'ZipCode' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject DeleteZipCode(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
                DeleteZipCodeStoredProcedure deleteZipCodeProc = null;

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

                    // verify zipCode exists
                    if (zipCode != null)
                    {
                        // Now create deleteZipCodeProc from ZipCodeWriter
                        // The DataWriter converts the 'ZipCode'
                        // to the SqlParameter[] array needed to delete a 'ZipCode'.
                        deleteZipCodeProc = ZipCodeWriter.CreateDeleteZipCodeStoredProcedure(zipCode);
                    }
                }

                // Verify deleteZipCodeProc exists
                if (deleteZipCodeProc != null)
                {
                    // Execute Delete Stored Procedure
                    bool deleted = this.DataManager.ZipCodeManager.DeleteZipCode(deleteZipCodeProc, 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
        /// 'DeleteZipCode'StoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'ZipCode_Delete'.
        /// </summary>
        /// <param name="zipCode">The 'ZipCode' to Delete.</param>
        /// <returns>An instance of a 'DeleteZipCodeStoredProcedure' object.</returns>
        public static DeleteZipCodeStoredProcedure CreateDeleteZipCodeStoredProcedure(ZipCode zipCode)
        {
            // Initial Value
            DeleteZipCodeStoredProcedure deleteZipCodeStoredProcedure = new DeleteZipCodeStoredProcedure();

            // Now Create Parameters For The DeleteProc
            deleteZipCodeStoredProcedure.Parameters = CreatePrimaryKeyParameter(zipCode);

            // return value
            return(deleteZipCodeStoredProcedure);
        }
Пример #3
0
        /// <summary>
        /// This method deletes a 'ZipCode' object.
        /// </summary>
        /// <returns>True if successful false if not.</returns>
        /// </summary>
        public bool DeleteZipCode(DeleteZipCodeStoredProcedure deleteZipCodeProc, DataConnector databaseConnector)
        {
            // Initial Value
            bool deleted = false;

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

            // return value
            return(deleted);
        }