Ejemplo n.º 1
0
        internal int DoAddCategory(String name, DbTransaction transaction)
        {
            // Insert into categories table
            String insertCommand = String.Format("INSERT INTO {0} ({1}) VALUES (@Id)", Schema.CATEGORIES_TABLE, Schema.ID_COLUMN);

            using (DbCommand command = DbUtils.CreateDbCommand(insertCommand, m_Connection, transaction))
            {
                command.AddParameterWithValue("@Id", DBNull.Value);
                int res = command.ExecuteNonQuery();
                if (res != 1)
                {
                    throw new TagsDbException("Insertion into Category table failed.");
                }
            }
            long newId = m_Connection.LastInsertRowId();

            // Insert name into translation table
            TagsTranslations.DoAddTranslation(m_Connection, transaction, Schema.CATEGORYNAMES_TABLE, Schema.CATEGORY_COLUMN, Schema.LANGUAGE_COLUMN, newId, m_LanguageId, name);

            return((int)newId);
        }