Exemplo n.º 1
0
        private void DeleteCategory()
        {
            СonfirmationViewModel confirmVM = new СonfirmationViewModel("Do you really want to delete this category?");

            Views.СonfirmationView confirmView = new Views.СonfirmationView();
            confirmView.DataContext = confirmVM;
            confirmView.ShowDialog();

            if (confirmVM.Result)
            {
                try
                {
                    storageHandler.RemoveCategory(SelectedCategory);
                }
                catch (FileNotFoundException ex)
                { MessageBox.Show($"File not found {ex.Message}."); }
                catch (InvalidOperationException ex)
                { MessageBox.Show($"Can't save data to file {ex.Message}."); }
                catch (Exception ex)
                { MessageBox.Show($"Something is wrong {ex.Message}."); }

                SelectedCategory = null;
                GetCategories();
            }
        }