public static City GetCity(String baseUrl, String stationDetailsPostfix)
{
XDocument xDoc = XDocument.Load(baseUrl + "service/carto");
var stations = (from c in xDoc.Descendants("carto").Descendants("markers").Descendants("marker")
select new Station
{
Address = ((string)c.Attribute("address")).Replace("-","").ToLower(),
Id = (int)c.Attribute("number"),
Lat = (double)c.Attribute("lat"),
Lng = (double)c.Attribute("lng"),
//initialize Free to -1 - if the client obtains -1 it will show it orange - as we do not have the correct information
Free = -1,
//no info yet
IsUpdate = false
}).ToList();
try
{
//update values for each station
foreach (var station in stations)
{
String url = baseUrl + "service/stationdetails/" + stationDetailsPostfix + station.Id;
XDocument stationDoc = XDocument.Load(url);
var updateStation = (from c in stationDoc.Descendants("station")
select new Station
{
Free = (int)c.Element("available"),
Total = (int)c.Element("total"),
Ticket = (int)c.Element("ticket")
}).First();
station.Free = updateStation.Free;
station.Total = updateStation.Total;
}
}
catch (Exception ex)
{
_log.Info("Decaux: - Error while getting information about station: " + ex);
}
City city = new City
{
Stations = stations,
TimeStamp = DateTime.Now
};
return city;
}