public static void AddCheevo(string title, string description, string category, int points)
{
var addCmd = "INSERT INTO available_cheevos(ID, Title, Description, Category, Points) VALUES(NULL, @title, @description, @category, @points)";
bool dbOpened = false;
lock (Database.sqliteCon)
{
try
{
Database.sqliteCon.Open();
dbOpened = true;
using (SQLiteTransaction sqlTransaction = sqliteCon.BeginTransaction())
using (SQLiteCommand addCommand = new SQLiteCommand(addCmd, sqliteCon, sqlTransaction))
{
addCommand.Parameters.AddWithValue("@title", title );
addCommand.Parameters.AddWithValue("@description", description );
addCommand.Parameters.AddWithValue("@category", category );
addCommand.Parameters.AddWithValue("@points", points );
try
{
addCommand.ExecuteNonQuery();
sqlTransaction.Commit();
}
catch
{
// do nothing, cheevo already added
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message + " " + ex.StackTrace);
}
finally
{
if (dbOpened)
{
Database.sqliteCon.Close();
}
}
}
}