public Game(int id, string name, Checkpoint checkpoint, Theme theme, float budget, float time, float timeConsumption) : this(id, name) { this.CurrentCheckpoint = checkpoint; this.Theme = theme; this.Budget = budget; this.Time = time; this.TimeConsumption = timeConsumption; }
public void Add(Theme theme) { try { List<ColumnValue> columns = new List<ColumnValue> (); columns.Add (new ColumnValue () { Item1 = "id", Item2 = theme.Id.ToString() }); columns.Add (new ColumnValue () { Item1 = "name", Item2 = theme.Name }); columns.Add (new ColumnValue () { Item1 = "iconId", Item2 = theme.IconId.ToString() }); this.Insert (columns); } catch (MySqlException ex) { switch (ex.Number) { case 0: throw new DatabaseException ("Cannot connect to server. Contact administrator", ex); case 1045: throw new DatabaseException ("Invalid username/password, please try again", ex); default: throw new DatabaseException (ex.Message, ex); } } }
public void Delete(Theme theme) { try { StatementValue where = new StatementValue (); where.Item1 = "id = @StatementValue0"; where.Item2 = new List<string> (); where.Item2.Add (theme.Id.ToString ()); this.Delete (where); } catch (MySqlException ex) { switch (ex.Number) { case 0: throw new DatabaseException ("Cannot connect to server. Contact administrator", ex); case 1045: throw new DatabaseException ("Invalid username/password, please try again", ex); default: throw new DatabaseException (ex.Message, ex); } } }
public void Save(Theme theme) { try { ColumnValue name = new ColumnValue () { Item1 = "name", Item2 = theme.Name }; ColumnValue iconId = new ColumnValue () { Item1 = "iconId", Item2 = theme.IconId.ToString() }; List<ColumnValue> columns = new List<ColumnValue> (); columns.Add (name); columns.Add (iconId); StatementValue where = new StatementValue (); where.Item1 = "id = @StatementValue0"; where.Item2 = new List<string> (); where.Item2.Add (theme.Id.ToString ()); this.Update (columns, where); } catch (MySqlException ex) { switch (ex.Number) { case 0: throw new DatabaseException ("Cannot connect to server. Contact administrator", ex); case 1045: throw new DatabaseException ("Invalid username/password, please try again", ex); default: throw new DatabaseException (ex.Message, ex); } } }