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); } }
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); } }
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); } }
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); } }
public static void Update(Note note) { if (note == null) { throw new Exception(LanguageDictionary.GetValue("UpdateNoteOperationInputDataError")); } var connection = SingltoneConnection.GetInstance(); var result = connection.Update(note, typeof(Note)); if (result == 0) { throw new Exception(LanguageDictionary.GetValue("UpdateNoteOperationUnknownError")); } }
public static void Delete(int id) { if (id < 0) { throw new Exception(LanguageDictionary.GetValue("DeleteNoteOperationInputError")); } var connection = SingltoneConnection.GetInstance(); var rows = connection.Delete <Note>(id); if (rows == 0) { throw new Exception(LanguageDictionary.GetFormatValue("DeleteNoteOperationUnknownError", id)); } }
public static void Insert(Note newNote) { if (newNote == null) { throw new Exception(LanguageDictionary.GetValue("AddNoteOperationInputDataError")); } var connection = SingltoneConnection.GetInstance(); var result = connection.Insert(newNote); if (result == 0) { throw new Exception(LanguageDictionary.GetValue("AddNoteOperationUnknownError")); } }
public static Note Get(int id) { if (id < 0) { throw new Exception(LanguageDictionary.GetValue("GetNoteOperationInputError")); } var connection = SingltoneConnection.GetInstance(); var res = connection.Table <Note>().FirstOrDefault(o => o.Id == 2); if (res == null) { throw new Exception(LanguageDictionary.GetFormatValue("GetNoteOperationUnknownError", id)); } return(res); }