public List <KeyValuePair <string, string> > GetTopStationCountLocations(int count) { List <KeyValuePair <string, string> > locationList = new List <KeyValuePair <string, string> >(); List <charging_station_data> dataList = new List <charging_station_data>(); foreach (metropolitan_area metro in _dl.GetAllMetropolitanAreas()) { location location = _dl.GetLocationsByMetropolitanAreaId(metro.id).FirstOrDefault(); charging_station_data chargingStationData = _dl.GetChargingStationDataByPostalCode(location.postal_code).LastOrDefault(); dataList.Add(chargingStationData); } foreach (charging_station_data item in dataList.OrderByDescending(x => x.station_count).Take(count)) { location location = _dl.GetLocationByPostalCode(item.postal_code); state state = _dl.GetStateByStateCode(location.state); locationList.Add(new KeyValuePair <string, string>(location.city.ToLower(), state.state_name.ToLower())); } return(locationList); }
/// <summary> /// Retrieve's the latest location data from the database for plotting on a map /// </summary> /// <returns></returns> private List <MapData> GetMapData() { List <MapData> list = new List <MapData>(); foreach (metropolitan_area metro in _data.GetAllMetropolitanAreas()) { location location = _data.GetLocationsByMetropolitanAreaId(metro.id).FirstOrDefault(); charging_station_data chargingStationData = _data.GetChargingStationDataByPostalCode(location.postal_code).LastOrDefault(); list.Add(new MapData() { Latitude = location.latitude.ToString(), Longitude = location.longitude.ToString(), Stations = Convert.ToInt32(chargingStationData.station_count), Ports = Convert.ToInt32(chargingStationData.port_count), City = location.city, State = location.state }); } ; return(list); }