Ejemplo n.º 1
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);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 3
0
 public AddEditNoteView(AddEditNoteViewModel vm)
 {
     InitializeComponent();
     DataContext = vm;
 }