示例#1
0
        /// <summary>
        /// This method updates a 'Image'.
        /// This method uses the 'Image_Update' procedure.
        /// </summary>
        /// <returns>True if successful false if not.</returns>
        /// </summary>
        public bool UpdateImage(UpdateImageStoredProcedure updateImageProc, DataConnector databaseConnector)
        {
            // Initial Value
            bool saved = false;

            // Verify database connection is connected
            if ((databaseConnector != null) && (databaseConnector.Connected))
            {
                // Execute Update.
                saved = this.DataHelper.UpdateRecord(updateImageProc, databaseConnector);
            }

            // return value
            return(saved);
        }
示例#2
0
        /// <summary>
        /// This method creates an instance of an
        /// 'UpdateImageStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Image_Update'.
        /// </summary>
        /// <param name="image"The 'Image' object to update</param>
        /// <returns>An instance of a 'UpdateImageStoredProcedure</returns>
        public static UpdateImageStoredProcedure CreateUpdateImageStoredProcedure(Image image)
        {
            // Initial Value
            UpdateImageStoredProcedure updateImageStoredProcedure = null;

            // verify image exists
            if (image != null)
            {
                // Instanciate updateImageStoredProcedure
                updateImageStoredProcedure = new UpdateImageStoredProcedure();

                // Now create parameters for this procedure
                updateImageStoredProcedure.Parameters = CreateUpdateParameters(image);
            }

            // return value
            return(updateImageStoredProcedure);
        }
        /// <summary>
        /// This method updates a 'Image' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Image' to update.
        /// <returns>A PolymorphicObject object with a value.
        internal PolymorphicObject UpdateImage(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            Image image = null;

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

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

                    // verify image exists
                    if (image != null)
                    {
                        // Now create updateImageProc from ImageWriter
                        // The DataWriter converts the 'Image'
                        // to the SqlParameter[] array needed to update a 'Image'.
                        updateImageProc = ImageWriter.CreateUpdateImageStoredProcedure(image);
                    }

                    // Verify updateImageProc exists
                    if (updateImageProc != null)
                    {
                        // Execute Update Stored Procedure
                        bool saved = this.DataManager.ImageManager.UpdateImage(updateImageProc, 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);
        }