Exemplo n.º 1
0
        /// <summary>
        /// This method creates an instance of a
        /// 'FindArtistStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Artist_Find'.
        /// </summary>
        /// <param name="artist">The 'Artist' to use to
        /// get the primary key parameter.</param>
        /// <returns>An instance of an FetchUserStoredProcedure</returns>
        public static new FindArtistStoredProcedure CreateFindArtistStoredProcedure(Artist artist)
        {
            // Initial Value
            FindArtistStoredProcedure findArtistStoredProcedure = null;

            // verify artist exists
            if (artist != null)
            {
                // Instanciate findArtistStoredProcedure
                findArtistStoredProcedure = new FindArtistStoredProcedure();

                // if artist.FindByEmailAddress is true
                if (artist.FindByEmailAddress)
                {
                    // Change the procedure name
                    findArtistStoredProcedure.ProcedureName = "Artist_FindByEmailAddress";

                    // Create the @EmailAddress parameter
                    findArtistStoredProcedure.Parameters = SqlParameterHelper.CreateSqlParameters("@EmailAddress", artist.EmailAddress);
                }
                else
                {
                    // Now create parameters for this procedure
                    findArtistStoredProcedure.Parameters = CreatePrimaryKeyParameter(artist);
                }
            }

            // return value
            return(findArtistStoredProcedure);
        }
        /// <summary>
        /// This method finds a  'Artist' object.
        /// This method uses the 'Artist_Find' procedure.
        /// </summary>
        /// <returns>A 'Artist' object.</returns>
        /// </summary>
        public Artist FindArtist(FindArtistStoredProcedure findArtistProc, DataConnector databaseConnector)
        {
            // Initial Value
            Artist artist = null;

            // Verify database connection is connected
            if ((databaseConnector != null) && (databaseConnector.Connected))
            {
                // First Get Dataset
                DataSet artistDataSet = this.DataHelper.LoadDataSet(findArtistProc, databaseConnector);

                // Verify DataSet Exists
                if (artistDataSet != null)
                {
                    // Get DataTable From DataSet
                    DataRow row = this.DataHelper.ReturnFirstRow(artistDataSet);

                    // if row exists
                    if (row != null)
                    {
                        // Load Artist
                        artist = ArtistReader.Load(row);
                    }
                }
            }

            // return value
            return(artist);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method finds a 'Artist' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Artist' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject FindArtist(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            Artist artist = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Find StoredProcedure
                FindArtistStoredProcedure findArtistProc = null;

                // verify the first parameters is a 'Artist'.
                if (parameters[0].ObjectValue as Artist != null)
                {
                    // Get ArtistParameter
                    Artist paramArtist = (Artist)parameters[0].ObjectValue;

                    // verify paramArtist exists
                    if (paramArtist != null)
                    {
                        // Now create findArtistProc from ArtistWriter
                        // The DataWriter converts the 'Artist'
                        // to the SqlParameter[] array needed to find a 'Artist'.
                        findArtistProc = ArtistWriter.CreateFindArtistStoredProcedure(paramArtist);
                    }

                    // Verify findArtistProc exists
                    if (findArtistProc != null)
                    {
                        // Execute Find Stored Procedure
                        artist = this.DataManager.ArtistManager.FindArtist(findArtistProc, dataConnector);

                        // if dataObject exists
                        if (artist != null)
                        {
                            // set returnObject.ObjectValue
                            returnObject.ObjectValue = artist;
                        }
                    }
                }
                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 a
        /// 'FindArtistStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Artist_Find'.
        /// </summary>
        /// <param name="artist">The 'Artist' to use to
        /// get the primary key parameter.</param>
        /// <returns>An instance of an FetchUserStoredProcedure</returns>
        public static FindArtistStoredProcedure CreateFindArtistStoredProcedure(Artist artist)
        {
            // Initial Value
            FindArtistStoredProcedure findArtistStoredProcedure = null;

            // verify artist exists
            if (artist != null)
            {
                // Instanciate findArtistStoredProcedure
                findArtistStoredProcedure = new FindArtistStoredProcedure();

                // Now create parameters for this procedure
                findArtistStoredProcedure.Parameters = CreatePrimaryKeyParameter(artist);
            }

            // return value
            return(findArtistStoredProcedure);
        }