public void SaveCountriesAndCities() { this.log.Debug("Places parsing started"); IVkDataProvider vkDataProvider = this.vkConnectionBuilder.GetVkDataProvider(); CountriesReponse countries = vkDataProvider.GetCountries(); this.SaveCountries(countries); this.log.Debug("Countries are saved"); int offset = 0; while (true) { CitiesReponse cities = vkDataProvider.GetCities(offset); this.SaveCities(cities); if (cities != null && cities.city != null && cities.city.Length > 0 && this.NonEmptyTitleExists(cities)) { offset += cities.city.Length; } else { break; } } this.log.Debug("Places parsing finished"); }
private void SaveCountries(CountriesReponse countries) { if (countries == null || countries.country == null || countries.country.Length <= 0) { return; } foreach (var c in countries.country) { Country country = new Country { VkId = c.cid, Title = c.title }; this.placeRepository.Save(country); } }