Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private bool AddNewCity(string cityName, string countryIso)
{
var city = CountriesCitiesDbService.GetNewCity();
var europeanCountries = CountriesCitiesDbService.GetAllEuropeanCountries();
var country = europeanCountries.FirstOrDefault(ec => ec.IsoCode.Equals(countryIso));
if (country == null)
throw new ArgumentException($"Country with ISO Code {countryIso} does not exist!");
city.Name = cityName;
city.Country = country;
CountriesCitiesDbService.SaveCity(city);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment