private void SubmitChange_Click(object sender, RoutedEventArgs e) { string city = ChangeCurrentCity.Text; string address = ChangeAddress.Text; string[] parts = city.Split(", "); string[] parts2 = address.Split(", "); City c = new City(parts[0], new State(parts[1])); try { if (!cityController.CheckIfExists(c)) { cityController.CreateCity(c); } else { c = cityController.GetCityByName(c); } Address a = new Address(parts2[0], int.Parse(parts2[1]), 0, 0, c); if (addressController.CheckIfExists(a)) { a = addressController.GetExistentAddress(a); } else { a = addressController.CreateAddress(a); } var dr = MainWindow.doctor; validate.IsEmailValid(ChangeEmail.Text); dr.Email = ChangeEmail.Text; dr.Phone = ChangePhoneNumber.Text; dr.CurrResidence = a; userController.UpdateUserProfile(dr); MainWindow.doctor = (Doctor)userController.GetUser(MainWindow.doctor.Username); NavigationService.Navigate(new Uri("/Pages/ProfileAndNotification/Profile.xaml", UriKind.Relative)); NavigationService.Navigate(new Uri("/Pages/ProfileAndNotification/Profile.xaml", UriKind.Relative)); } catch (IncorrectEmailAddress) { Napomena.Visibility = Visibility.Collapsed; Error.Text = "Nevalidan format email adrese!"; ErrorMessage.Visibility = Visibility.Visible; } catch (Exception) { Napomena.Visibility = Visibility.Collapsed; Error.Text = "Došlo je do neke greške!"; ErrorMessage.Visibility = Visibility.Visible; } }