public ZoneRoamAreasDatabase(string zone, MySqlConnection connection, QueryConfig config) : base(zone, config) { _connection = connection; var sql = String.Format(SelectString, SelectArgValues); var results = Database.QueryHelper.RunQuery(_connection, sql); foreach (var row in results) { var ra = new RoamArea(_queryConfig); ra.SetProperties(Queries, row); RoamAreas.Add(ra); } foreach (var area in RoamAreas) { sql = String.Format(area.SelectString, area.SelectArgValues); results = Database.QueryHelper.RunQuery(_connection, sql); foreach (var row in results) { var entry = new RoamAreaEntry(_queryConfig); entry.SetProperties(area.Queries, row); area.Vertices.Add(entry); entry.Created(); } area.Created(); } this.Created(); }
public void RemoveEntry(RoamAreaEntry entry) { if (CreatedObj) { if (NeedsInserted.Contains(entry)) { //this waypoint was not retrieved from the database NeedsInserted.Remove(entry); } else { //waypoint was in the database NeedsDeleted.Add(entry); } } Vertices.Remove(entry); }
public void AddEntry(RoamAreaEntry entry) { if (entry.RoamAreaId != Id || entry.Zone != this.Zone || entry.Number < GetNextNewEntryNumber()) { throw new Exception("Attempted to add conflicting roam area entry, request a roam area entry before adding via GetNewEntry method"); } this.Vertices.Add(entry); entry.RoamAreaId = Id; // object was finalized, any changes now are recorded if (CreatedObj) { NeedsInserted.Add(entry); } }
public RoamAreaEntry GetNewEntry() { int newId = GetNextNewEntryNumber(); RoamAreaEntry entry = new RoamAreaEntry(newId, this.Id, _zone, _queryConfig); entry.Created(); return entry; }
public void AddEntry() { RoamAreaEntry entry = new RoamAreaEntry(GetNextNewEntryNumber(), this.Id, _zone,_queryConfig); AddEntry(entry); }