public static List <TerritoryIDType> GetNeighborTerritories(TerritoryIDType territory) { MapDetails map = GameState.Map; List <TerritoryDetails> territoryDetails = map.Territories.Select(o => o.Value).ToList(); TerritoryDetails territoryInQuestion = territoryDetails.Where(o => o.ID == territory).First(); List <TerritoryIDType> connectedTerritoryIds = territoryInQuestion.ConnectedTo.Keys.ToList(); return(connectedTerritoryIds); }
public TerritoryDetails GetTerritoryDetails(int TerritoryId) { TerritoryDetails tds = new TerritoryDetails(); var td = (from t in db.Territories.Include(tb => tb.TerritoryBounds).Include(d => d.Doors) where t.Id == TerritoryId select t).SingleOrDefault(); if (td != null) { tds = new TerritoryDetails() { Id = td.Id, TerritoryName = td.TerritoryName, City = td.City, TerritoryTypeStr = td.TerritoryType != null ? td.TerritoryType.Description : "", Notes = td.Notes, DoorCount = td.Doors != null ? td.Doors.Count : 0, //AssignedPublisher = t. CheckedOut = td.CheckedOut, CheckedIn = td.CheckedIn, LastCheckedInBy = td.LastCheckedInBy, TerritoryBounds = new List <TerritoryDetails.TerritoryBound>() }; //TerritoryBounds if (td.TerritoryBounds != null) { foreach (var tb in td.TerritoryBounds) { tds.TerritoryBounds.Add(new TerritoryDetails.TerritoryBound() { GeoLat = decimal.ToDouble(tb.GeoLat), GeoLong = decimal.ToDouble(tb.GeoLong) }); } } } return(tds); }