Skip to content

Instantly share code, notes, and snippets.

@dsibinski
Created March 12, 2017 13:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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