private void OnAddNewCategoryExecute(int?obj)
        {
            var strkey = obj.ToString();

            AddCategoryViewModel vm = new AddCategoryViewModel()
            {
                CategoryTitle = "Новая категория"
            };

            int.TryParse(strkey, out int parentKey);


            AddCategoryDialog dlg = new AddCategoryDialog()
            {
                DataContext = vm
            };
            var result = dlg.ShowDialog();

            if (result == true)
            {
                Category category = new Category()
                {
                    CategoryTitle = vm.CategoryTitle
                };
                if (parentKey > 0)
                {
                    category.ParentCategoryKey = parentKey;
                }

                _categoryRepository.Add(category);
                _categoryRepository.Save();
                CategoryNavigationViewModel.Load();
            }
        }
        public FilesOnDriveViewModel(
            IEventAggregator eventAggregator
            , IMessageDialogService messageDialogService
            , IArchiveEntityRepository repository
            , ICategoryNavigationViewModel categoryNavigationViewModel
            , ICategoryRepository categoryRepository
            , ITagRepository tagRepository
            , IAppLogger appLogger
            ) : base(eventAggregator, messageDialogService, appLogger)
        {
            _categoryRepository          = categoryRepository;
            _categoryNavigationViewModel = categoryNavigationViewModel;
            _tagRepository        = tagRepository;
            _repository           = repository;
            _eventAggregator      = eventAggregator;
            _messageDialogService = messageDialogService;
            _eventAggregator.GetEvent <SelectedItemChangedEvent>().Subscribe(OnSelectedItemChanged);

            Tags       = new ObservableCollection <TagWrapper>();
            Categories = new ObservableCollection <CategoryWrapper>();
            Images     = new ObservableCollection <ImageWrapper>();

            CategoryNavigationViewModel.Load();

            #region Commands
            AddTagCommand = new DelegateCommand <string>(OnAddTagExecute, OnAddTagCanExecute);

            MultyAddTagCommand = new DelegateCommand <string>(OnAddMultyTagExecute, OnAddMultyTagCanExecute);

            AddCategoryCommand                = new DelegateCommand <int?>(OnAddCategoryExecute, OnAddCategoryCanExecute);
            AddNewCategoryCommand             = new DelegateCommand <int?>(OnAddNewCategoryExecute, OnAddNewCategoryCanExecute);
            OpenFileDialogCommand             = new DelegateCommand(OnOpenFileDialogExecute, OnOpenFileDialogCanExecute);
            DeleteTagCommand                  = new DelegateCommand <string>(OnDeleteTagExecute, OnDeleteTagCanExecute);
            DeleteImageCommand                = new DelegateCommand <int?>(OnDeleteImageExecute, OnDeleteImageCanExecute);
            DeleteCategoryToEntityCommand     = new DelegateCommand <int?>(OnDeleteCategoryToEntityExecute, OnDeleteCategoryToEntityCanExecute);
            CloseSearchDetailViewModelCommand = new DelegateCommand(OnCloseSearchDetailViewExecute);
            EditDescriptionCommand            = new DelegateCommand(OnEditDescriptionViewExecute);
            MultyAddCategoryCommand           = new DelegateCommand <int?>(OnMultyAddCategoryExecute, OnMultyAddCategoryCanExecute);

            #endregion
        }
 public void Load()
 {
     CategoryNavigationViewModel.Load();
     TagNavigationViewModel.Load();
 }