/// <summary>
        /// Saves a 'Noun' object into the database.
        /// This method calls the 'Insert' or 'Update' method.
        /// </summary>
        /// <param name='noun'>The 'Noun' object to save.</param>
        /// <returns>True if successful or false if not.</returns>
        public bool Save(ref Noun noun)
        {
            // Initial value
            bool saved = false;

            // If the noun exists.
            if (noun != null)
            {
                // Is this a new Noun
                if (noun.IsNew)
                {
                    // Insert new Noun
                    int newIdentity = this.Insert(noun);

                    // if insert was successful
                    if (newIdentity > 0)
                    {
                        // Update Identity
                        noun.UpdateIdentity(newIdentity);

                        // Set return value
                        saved = true;
                    }
                }
                else
                {
                    // Update Noun
                    saved = this.Update(noun);
                }
            }

            // return value
            return(saved);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method loads a 'Noun' object
        /// from the dataRow passed in.
        /// </summary>
        /// <param name='dataRow'>The 'DataRow' to load from.</param>
        /// <returns>A 'Noun' DataObject.</returns>
        public static Noun Load(DataRow dataRow)
        {
            // Initial Value
            Noun noun = new Noun();

            // Create field Integers
            int idfield        = 0;
            int syllablesfield = 1;
            int wordTextfield  = 2;

            try
            {
                // Load Each field
                noun.UpdateIdentity(DataHelper.ParseInteger(dataRow.ItemArray[idfield], 0));
                noun.Syllables = DataHelper.ParseInteger(dataRow.ItemArray[syllablesfield], 0);
                noun.WordText  = DataHelper.ParseString(dataRow.ItemArray[wordTextfield]);
            }
            catch
            {
            }

            // return value
            return(noun);
        }