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); } }
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); } }
public AddEditNoteView(AddEditNoteViewModel vm) { InitializeComponent(); DataContext = vm; }