private void Add_Click(object sender, RoutedEventArgs e) { City newType = new City(); newType.Name = Name_; newType.Country = (CountryComboBox.SelectedItem as Country); GetPropForSelectedService GettingService = new GetPropForSelectedService(); foreach (var type in GettingService.GetCities()) { if (type.Name == Name_) { MessageBox.Show($"{Name_} type alredy exists."); return; } } AddingService service = new AddingService(); service.AddCity(newType); MessageBox.Show("New city added."); }