This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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