//Saves changes private void btnSave_Click(object sender, RoutedEventArgs e) { // error checks if (txtUserName.Text == "") { MessageBox.Show("You must enter a first name."); txtUserName.Focus(); return; } if (!(txtEmail.Text.ToString().Length > 6 && txtEmail.Text.ToString().Contains("@") && txtEmail.Text.ToString().Contains("."))) { MessageBox.Show("You must enter a valid email address."); txtEmail.Focus(); return; } PokedexUser newUser = new PokedexUser() { PokedexUserName = txtUserName.Text.ToString(), Email = txtEmail.Text.ToString(), Active = (bool)chkActive.IsChecked }; if (_addMode) { try { if (_userManager.AddUser(newUser)) { this.DialogResult = false; this.Close(); } try { lstAssigned.ItemsSource = _userManager.RetrieveUserRoles(_user.PokedexUserID); } catch (Exception ex) { MessageBox.Show(ex.Message); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message); } } else { try { if (_userManager.EditUser(_user, newUser)) { // success this.DialogResult = true; this.Close(); } else { throw new ApplicationException("Data not Saved.", new ApplicationException("User may no longer exist."));; } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message); } } }