예제 #1
0
        /// <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);
        }