private void DeleteSelectedPatient(PatientToBeDeleted patientToBeDeleted) { //AllPatients.Remove(patientToBeDeleted.PatientToBeDeletedProperty); _patientDataService.DeletePatient(patientToBeDeleted.PatientToBeDeletedProperty); _dialogService.ClosePatientsDetailDialog(); var allPatients = _patientDataService.GetAllPatients(); var patientViewModels = allPatients.Select(x => PatientViewModel.FromModel(x)); AllPatients.Clear(); foreach (var patient in patientViewModels) { AllPatients.Add(patient); } }
public MainWindowViewModel(IDialogService dialogService, IPatientDataService patientDataService) { _dialogService = dialogService; _patientDataService = patientDataService; EditCommand = new CustomCommand(Edit, CanEdit); AllPatients = new ObservableCollection <PatientViewModel>(); Messenger.Default.Register <PatientToBeDeleted>(this, DeleteSelectedPatient); var allPatients = _patientDataService.GetAllPatients(); var patientViewModels = allPatients.Select(x => PatientViewModel.FromModel(x)); foreach (var patient in patientViewModels) { AllPatients.Add(patient); } }