Beispiel #1
0
        private void EditCategory()
        {
            CategoryModel newCategory = new CategoryModel {
                DataIndexes = new List <int>(SelectedCategory?.DataIndexes), Name = SelectedCategory.Name
            };
            CategoryValidateViewModel validateVM = new CategoryValidateViewModel(ref newCategory);

            Views.CategoryValidateView validateView = new Views.CategoryValidateView();
            validateView.DataContext = validateVM;
            validateView.ShowDialog();

            if (!SelectedCategory.Equals(newCategory))
            {
                try
                {
                    storageHandler.ReplaceCategory(SelectedCategory, newCategory);
                }
                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}."); }
                GetCategories();
            }
        }