Exemplo n.º 1
0
        private void ReturnFromArchive(Note note)
        {
            var confirmationViewSettings = new ModalWindowSettings
            {
                Title      = LanguageDictionary.GetValue("Confirmation"),
                ResizeMode = ResizeMode.NoResize
            };
            var confirmationView = ControlsCreator.GetSimpleTextView("UnarchiveNoteConfirmation", confirmationViewSettings);

            var result = ModalWindowPresenter.ShowModalOkCancel(confirmationView);

            if (result != true)
            {
                return;
            }
            try
            {
                // ReSharper disable once PossibleNullReferenceException
                note.IsArchived = false;
                NoteRepozitory.Update(note);
                FetchDataFromDatabase();
            }
            catch (Exception e)
            {
                ModalWindowPresenter.ShowErrorMessage("UnarchiveNoteException", e);
            }
        }
Exemplo n.º 2
0
        private void EditNoteExecute(object obj)
        {
            var viewModel = new AddEditNoteViewModel();
            var note      = obj as Note;

            if (note == null)
            {
                ModalWindowPresenter.ShowErrorMessage("EditNoteInputError");
                return;
            }

            var clone = note.Clone();

            viewModel.Note = clone;
            var view = new AddEditNoteView(viewModel);

            view.WindowSettings.Title = LanguageDictionary.GetValue("EditNote");
            var result = ModalWindowPresenter.ShowModalOkCancel(view);

            if (result != true)
            {
                return;
            }

            try
            {
                // ReSharper disable once PossibleNullReferenceException
                NoteRepozitory.Update(clone);
                FetchDataFromDatabase();
            }
            catch (Exception e)
            {
                ModalWindowPresenter.ShowErrorMessage("EditNoteException", e);
            }
        }
Exemplo n.º 3
0
        private void DeleteNoteExecute(object obj)
        {
            var confirmationViewSettings = new ModalWindowSettings
            {
                Title      = LanguageDictionary.GetValue("Confirmation"),
                ResizeMode = ResizeMode.NoResize
            };
            var confirmationView = ControlsCreator.GetSimpleTextView("DeleteNoteConfirmation", confirmationViewSettings);

            var result = ModalWindowPresenter.ShowModalOkCancel(confirmationView);

            if (result != true)
            {
                return;
            }
            var note = obj as Note;

            try
            {
                // ReSharper disable once PossibleNullReferenceException
                NoteRepozitory.Delete(note.Id);
                FetchDataFromDatabase();
            }
            catch (Exception e)
            {
                ModalWindowPresenter.ShowErrorMessage("DeleteNoteException", e);
            }
        }
Exemplo n.º 4
0
        private void AddNewNoteExecute()
        {
            _cts.Cancel();
            var viewModel = new AddEditNoteViewModel();
            var view      = new AddEditNoteView(viewModel);

            view.WindowSettings.Title = LanguageDictionary.GetValue("AddNote");
            var result = ModalWindowPresenter.ShowModalOkCancel(view);

            if (!result)
            {
                return;
            }
            //throw new Exception("test");
            try
            {
                // ReSharper disable once PossibleNullReferenceException
                NoteRepozitory.Insert(viewModel.Note);
                FetchDataFromDatabase();
            }
            catch (Exception e)
            {
                ModalWindowPresenter.ShowErrorMessage("AddNoteException", e);
            }
        }