public override LootTable CreateLootTable() { LootTable table = new LootTable(_connection, _queryConfig); int id = 0; var results = QueryHelper.TryRunQuery(_connection, "SELECT Max(id) as id FROM loottable;"); if (results.Count > 0) { id = Int32.Parse(results.ElementAt(0)["id"].ToString()) + 1; } //now check if our working set has an id greater then this... //caching this might make sense but for now it's not happening if (LootTables.Count > 0) { int curMax = LootTables.Max(x => x.Id); if (id <= curMax) { id = curMax + 1; } } table.Created(); table.Id = id; return table; }
public void AddLootTable(LootTable table) { if (_lootTables.Contains(table)) return; AddObject(table); _lootTables.Add(table); }
public override void Lookup(int id) { if (id >= 0 && _lootTables.Where(x => x.Id == id).Count() == 0) { var table = new LootTable(_connection, _queryConfig); table.Id = -1; table.Lookup(id); _lootTables.Add(table); } }
public void RemoveLootTable(LootTable table) { if (!_lootTables.Contains(table)) return; RemoveObject(table); _lootTables.Remove(table); }