Skip to content

Instantly share code, notes, and snippets.

@dsibinski
Created March 12, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsibinski/9e459fb3d6cd16567fc09f90ba948efb to your computer and use it in GitHub Desktop.
Save dsibinski/9e459fb3d6cd16567fc09f90ba948efb to your computer and use it in GitHub Desktop.
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