public async Task GetAndSaveStationsByName(char firstLetter) { var request = HttpConnector.CreateGetConnection(new Uri($"http://tarifgd.ru/tar_online2/getstan.php?buk={firstLetter}&poiskvh=1&pp=*&view=xml")); var response = await HttpConnector.Client.SendAsync(request); if (response.IsSuccessStatusCode) { var xmlResponse = await response.Content.ReadAsStreamAsync(); var stationSerializer = new XmlSerializer(typeof(StationXml)); var stationsXml = (StationXml)stationSerializer.Deserialize(xmlResponse); if (stationsXml.Stations != null) { foreach (var station in stationsXml.Stations) { await _stationService.Save(station); } Application.Current.Properties.Add("stationSavedByName" + firstLetter, 1); await Application.Current.SavePropertiesAsync().ConfigureAwait(false); } } }
public async Task GetAndSaveCargoByCode(char firstDigit) { var request = HttpConnector.CreateGetConnection(new Uri($"http://tarifgd.ru/tar_online2/getgruz.php?cod={firstDigit}&poiskvh=1&view=xml")); var response = await HttpConnector.Client.SendAsync(request); if (response.IsSuccessStatusCode) { var xmlResponse = await response.Content.ReadAsStreamAsync(); var cargoSerializer = new XmlSerializer(typeof(CargoXml)); var cargoXml = (CargoXml)cargoSerializer.Deserialize(xmlResponse); if (cargoXml.CargoList != null) { foreach (var cargo in cargoXml.CargoList) { await _cargoService.Save(cargo); } Application.Current.Properties.Add("cargoSavedByCode" + firstDigit, 1); await Application.Current.SavePropertiesAsync().ConfigureAwait(false); } } }