}// end of method Run /// <summary> /// Add new location locally if it does not already exists /// </summary> private void StoreNewLocationLocally() { string[] searchCity = city.Split(','); foreach (GeoNamesGeoLocation.GeoNames foundCity in GeoNamesGeoLocation.cityGeographicalData .geonames) { if (foundCity.name.Equals(searchCity[0].Trim().ToLower(), StringComparison.OrdinalIgnoreCase) && foundCity.adminCodes1.iso.Equals(searchCity[1].Trim(), StringComparison.OrdinalIgnoreCase) && !UtilityMethod.IsNumeric(foundCity.adminCodes1.iso) || foundCity.countryName.Equals(searchCity[1].Trim(), StringComparison.OrdinalIgnoreCase)) { string cityName = UtilityMethod.ToProperCase(foundCity.name); string countryName = UtilityMethod.ToProperCase(foundCity.countryName); string countryCode = foundCity.countryCode.ToUpper(); string regionName = UtilityMethod .ToProperCase(foundCity.adminName1); string regionCode = null; regionCode = foundCity.adminCodes1.iso?.ToUpper(); float Latitude = float.Parse(foundCity.lat); float Longitude = float.Parse(foundCity.lng); CityData cityData = new CityData(cityName, countryName, countryCode, regionName, regionCode, Latitude, Longitude); string currentCity = regionCode != null ? $"{cityName}, {regionCode}" : $"{cityName}, {countryName}"; if (!UtilityMethod.IsFoundInDatabase(currentCity)) { UtilityMethod.AddCityToDatabase(cityName, countryName, countryCode, regionName, regionCode, Latitude, Longitude); }// end of if block if (!UtilityMethod.IsFoundInJSONStorage(currentCity)) { JSONHelper.ExportToJSON(cityData); }// end of if block if (!UtilityMethod.IsFoundInXMLStorage(currentCity)) { XMLHelper.ExportToXML(cityData); } // end of if block } // end of if block } // end of for each loop } // end of method StoreNewLocationLocally