Esempio n. 1
0
        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");
            }
        }
Esempio n. 2
0
        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");
            }
        }
Esempio n. 3
0
        public void Handle(UserModel user)
        {
            User       = user;
            IsLoggedIn = true;

            Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(user.Id));
            Notes     = new BindableCollection <NoteModel>();
        }
Esempio n. 4
0
        public void DeleteNotebook()
        {
            int notebookId = SelectedNotebook.Id;

            SelectedNotebook = null;
            SelectedNote     = null;
            DBDataAccessDelete.DeleteNotebook(notebookId);
            Notes     = null;
            Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(User.Id));
        }
Esempio n. 5
0
        public void DeleteNote()
        {
            int noteId = SelectedNote.Id;

            SelectedNote = null;
            DBDataAccessDelete.DeleteNote(noteId);
            if (SelectedNotebook != null)
            {
                Notes = new BindableCollection <NoteModel>(DBDataAccessLoad.LoadNotebookNotes(SelectedNotebook.Id));
            }
        }
Esempio n. 6
0
        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");
            }
        }
Esempio n. 7
0
        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");
            }
        }
Esempio n. 8
0
        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();
            }
        }
Esempio n. 9
0
 protected override void OnActivate()
 {
     NotebooksCount = DBDataAccessLoad.LoadNotebooks(User.Id).Count;
     NotesCount     = DBDataAccessLoad.LoadUserNotes(User.Id).Count;
 }