public void ConfirmNewNoteTitle(string newNoteTitle) { NewNoteClicked = false; string cd = Environment.CurrentDirectory; string filePath = cd + $@"\data\{User.Id}" + $@"\{SelectedNotebook.Id}" + $@"\{newNoteTitle}.rtf"; NoteModel note = Notes.ToList <NoteModel>().Find(n => n.Title == newNoteTitle); if (note == null) { try { DBDataAccessInsert.InsertNote(new NoteModel() { NotebookId = SelectedNotebook.Id, Title = newNoteTitle, CreatedTime = DateTime.Now, UpdatedTime = DateTime.Now, FileLocation = filePath }); Notes.Clear(); Notes = new BindableCollection <NoteModel>(DBDataAccessLoad.LoadNotebookNotes(SelectedNotebook.Id)); } catch (SQLiteException) { MessageBox.Show("Invalid Title"); } } else { MessageBox.Show("Note with this title already exists"); } }
public void ConfirmNewNotebookName(string newNotebookName) { NewNotebookClicked = false; NotebookModel notebook = Notebooks.ToList <NotebookModel>().Find(n => n.Name == newNotebookName); if (notebook == null) { try { DBDataAccessInsert.InsertNotebook(new NotebookModel() { UserId = User.Id, Name = newNotebookName }); Notebooks.Clear(); Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(User.Id)); } catch (SQLiteException) { MessageBox.Show("Invalid Name"); } } else { MessageBox.Show("Notebook with this name already exists"); } }
public void Handle(UserModel user) { User = user; IsLoggedIn = true; Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(user.Id)); Notes = new BindableCollection <NoteModel>(); }
public void DeleteNotebook() { int notebookId = SelectedNotebook.Id; SelectedNotebook = null; SelectedNote = null; DBDataAccessDelete.DeleteNotebook(notebookId); Notes = null; Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(User.Id)); }
public void DeleteNote() { int noteId = SelectedNote.Id; SelectedNote = null; DBDataAccessDelete.DeleteNote(noteId); if (SelectedNotebook != null) { Notes = new BindableCollection <NoteModel>(DBDataAccessLoad.LoadNotebookNotes(SelectedNotebook.Id)); } }
public void ConfirmNoteTitleRename(string newTitle) { RenameNoteClicked = false; SelectedNote.Title = newTitle; try { DBDataAccessUpdate.UpdateNote(SelectedNote); Notes = new BindableCollection <NoteModel>(DBDataAccessLoad.LoadNotebookNotes(SelectedNotebook.Id)); } catch (SQLiteException) { MessageBox.Show("Note title already in use"); } }
public void ConfirmNotebookNameRename(string newName) { RenameNotebookClicked = false; SelectedNotebook.Name = newName; try { DBDataAccessUpdate.UpdateNotebook(SelectedNotebook); Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(User.Id)); SelectedNotebook = null; } catch (SQLiteException) { MessageBox.Show("Notebook name already in use"); } }
public void Login() { List <UserModel> users = DBDataAccessLoad.LoadUsers(); UserModel user = users.Find(u => (u.Username == LogUsername && u.Password == LogPassword)); if (user == null) { MessageBox.Show("Invalid Username or Password"); } else { MessageBox.Show("Login successful"); _eventAggregator.PublishOnUIThread(user); LogUsername = ""; LogPassword = null; RegName = ""; RegLastName = ""; RegEmail = ""; RegUsername = ""; RegPassword = ""; TryClose(); } }
protected override void OnActivate() { NotebooksCount = DBDataAccessLoad.LoadNotebooks(User.Id).Count; NotesCount = DBDataAccessLoad.LoadUserNotes(User.Id).Count; }