Ejemplo n.º 1
0
        private async void DoDeleteMedicalPractice()
        {
            var dialog = new UserDialogBox("",
                                           $"Praxis [{SelectedMedicalPractice.Name}] wirklich löschen?",
                                           MessageBoxButton.OKCancel);

            var result = await dialog.ShowMahAppsDialog();

            if (result == MessageDialogResult.Affirmative)
            {
                var practiceToDelete = SelectedMedicalPracticeObject;

                dataCenter.RemoveMedicalPractice(practiceToDelete);
                MedicalPractices.Remove(SelectedMedicalPractice);

                foreach (var user in dataCenter.GetAllUsers())
                {
                    if (user.ListOfAccessableMedicalPractices.Contains(practiceToDelete.Id))
                    {
                        var updatedUser = user.UpdateListOfAccessableMedicalPractices(
                            user.ListOfAccessableMedicalPractices.Where(medPracId => medPracId != practiceToDelete.Id)
                            .ToList()
                            );
                        dataCenter.UpdateUser(updatedUser);
                    }
                }

                SelectedMedicalPractice = null;
            }
        }