private void ButtonAddPatient_Click(object sender, RoutedEventArgs e) { try { var dlg = new PatientDialogView(ViewModel.VetClinic.Patients) { Owner = this }; dlg.ShowDialog(); if (dlg.DialogResult == true) { ViewModel.AddPatient(dlg.ViewModel.Patient); } } catch (Exception) { MessageBox.Show("Unexpected error occurred during register patient"); } }
private void BtnEditPatient_Click(object sender, RoutedEventArgs e) { try { var button = sender as Button; var pet = button.DataContext as Pet; var dlg = new PatientDialogView(ViewModel.MainWindowViewModel.VetClinic.Patients, pet) { Owner = this }; dlg.ShowDialog(); if (dlg.DialogResult == true) { ViewModel.EditPatient(dlg.ViewModel.Patient); } } catch (Exception) { MessageBox.Show("Unexpected error occurred during editing patient"); } }