Beispiel #1
0
        public async void ReadNotebooks()
        {
            //{
            //    using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            //    {
            //        conn.CreateTable<NotebookModel>(); //Make sure the table exists...
            //        var notebooks = conn.Table<NotebookModel>().ToList();

            //        Notebooks.Clear();
            //        foreach (var notebook in notebooks)
            //        {
            //            Notebooks.Add(notebook);
            //        }
            //    }


            try
            {
                //Ver que ahora ya sólo leemos los notebooks del usuario que se ha logado...
                var notebooks = await App.MobileServiceClient.GetTable <NotebookModel>().Where(n => n.UserId == App.UserId).ToListAsync();

                Notebooks.Clear();
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }

                //selectedNotebook= Notebooks.FirstOrDefault(); //weird behavbour
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #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");
            }
        }
Beispiel #3
0
        public async void ReadNoteBooks()
        {
            #region Commented Code
            //using (SQLiteConnection conn = new SQLiteConnection(DatabaseHelper.dbFile))
            //{
            //    conn.CreateTable<NoteBook>();

            //    //int userid = int.Parse(App.UserId);
            //    var notebooks = conn.Table<NoteBook>().ToList();
            //    Notebooks.Clear();
            //    if (notebooks != null)
            //    {
            //        foreach (var notebook in notebooks)
            //        {
            //            Notebooks.Add(notebook);
            //        }
            //    }

            //}
            #endregion

            var notebooks = await App.mobileServiceClient.GetTable <NoteBook>().OrderBy(n => n.Name).ToListAsync();

            Notebooks.Clear();
            if (notebooks != null)
            {
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
        }
Beispiel #4
0
        public async void ReadNotebooks()
        {
            //using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.GetFileLocation()))
            //{
            //	//int userId;
            //	//bool isLogged = int.TryParse(App.UserId, out userId);
            //	var notebooks = conn.Table<Notebook>()/*.Where(n => isLogged && n.UserId == userId)*/.ToList();

            //	Notebooks.Clear();
            //	foreach (var notebook in notebooks)
            //	{
            //		Notebooks.Add(notebook);
            //	}
            //}

            try
            {
                var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync();

                Notebooks.Clear();
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
        public async void ReadNotebooks()
        {
            ////using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            ////{
            ////    var notebooks = conn.Table<Notebook>().ToList();

            ////    Notebooks.Clear();
            ////    foreach(var notebook in notebooks)
            ////    {
            ////        Notebooks.Add(notebook);
            ////    }
            ////}

            try
            {
                var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync();

                Notebooks.Clear();
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #6
0
        public async void ReadNotebooks()
        {
#if USEAZURE
            try
            {
                Notebooks.Clear();

                var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync();

                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
            catch (Exception ex)
            {
            }
#else
            using (SQLiteConnection conn = new SQLiteConnection(DatabaseHelper.dbFile)) {
                var notebooks = conn.Table <Notebook>().ToList();

                Notebooks.Clear();

                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
#endif
        }
        private void CreateNotebook(object arg)
        {
            MainWindowInstance.ShowInputAsync("Add notebook", "Name:").ContinueWith(delegate(Task <string> task)
            {
                string newName = task.Result;
                if (string.IsNullOrEmpty(newName))
                {
                    return;
                }

                Notebook nb = new Notebook
                {
                    Name    = newName,
                    Created = DateTime.Now
                };
                nb.Save();

                var newNotebook = ViewModelLocator.Instance.GetNotebookViewModel(nb);

                List <NotebookViewModel> temp = new List <NotebookViewModel>();
                temp.AddRange(Notebooks.ToArray());
                temp.Add(newNotebook);
                temp.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal));

                Notebooks.Clear();
                temp.ForEach(Notebooks.Add);

                SelectedNotebook            = newNotebook;
                SelectedNotebook.IsSelected = true;
            });
        }
Beispiel #8
0
        private async void NewNotebook()
        {
            await App.MobileServiceClient.GetTable <Notebook>().InsertAsync(CreateNewNotebook());

            Notebooks.Clear();

            ReadNotebooks();
        }
 public void ReadNotebooks()
 {
     using (SQLiteConnection connection = new SQLiteConnection(DataBaseHelper.dbFile))
     {
         var notebooks = connection.Table <Notebook>().ToList();
         Notebooks.Clear();
         notebooks.ForEach(x => Notebooks.Add(x));
     }
 }
        public async void ReadNotebooks()
        {
            //using (var connection = new SQLite.SQLiteConnection(DatabaseHelper.DatabaseFile))
            //{
            //    try
            //    {
            //        string userId = App.UserId;
            //        if (!string.IsNullOrEmpty(userId))
            //        {
            //            var notebooks = connection.Table<Notebook>().Where(x => x.UserId == userId).ToList();

            //            Notebooks.Clear();
            //            foreach (var notebook in notebooks)
            //            {
            //                Notebooks.Add(notebook);
            //            }
            //        }
            //        else
            //        {
            //            Notebooks.Clear();
            //        }
            //    }
            //    catch (SQLite.SQLiteException)
            //    {
            //        // TODO logging or information should get shown here?

            //        Notebooks.Clear();
            //    }
            //}

            try
            {
                string userId = App.UserId;
                if (!string.IsNullOrEmpty(userId))
                {
                    var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == userId).ToListAsync();

                    Notebooks.Clear();
                    foreach (var notebook in notebooks)
                    {
                        Notebooks.Add(notebook);
                    }

                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Notebooks)));
                }
                else
                {
                    Notebooks.Clear();
                }
            }
            catch (Exception e)
            {
            }

            // Refreshing now
            ReadNotes();
        }
Beispiel #11
0
        public void ReadNotebooks()
        {
            var notebooks = DatabaseHelper.Table <Notebook>();

            Notebooks.Clear();
            foreach (var notebook in notebooks)
            {
                Notebooks.Add(notebook);
            }
        }
Beispiel #12
0
        public async Task GetNotebooks()
        {
            IEnumerable <Notebook> notebooks = (await DatabaseHelper.Read <Notebook>()).Where(n => n.UserId == App.UserID).ToList();

            Notebooks.Clear();
            foreach (var notebook in notebooks)
            {
                Notebooks.Add(notebook);
            }
        }
Beispiel #13
0
        private void GetNotebooks()
        {
            var notebooks = DatabaseHelper.Read <Notebook>();

            Notebooks.Clear();
            foreach (var notebook in notebooks)
            {
                Notebooks.Add(notebook);
            }
        }
Beispiel #14
0
        public async void getNotebooks()
        {
            var notebooks = (await DatabaseHelper.Read <Notebook>()).Where(n => n.UserId == App.UserId).ToList();

            Notebooks.Clear();
            foreach (var o in notebooks)
            {
                Notebooks.Add(o);
            }
        }
Beispiel #15
0
        private void GetNotebooks()
        {
            var notebooks = DatabaseHelper.Read <Notebook>();

            Notebooks.Clear();
            foreach (var notebook in notebooks)
            {
                Notebooks.Add(notebook);
                //Observable collection a ekleniyor
            }
        }
Beispiel #16
0
 public void Handle(string message)
 {
     if (message == "Sign out")
     {
         User       = null;
         IsLoggedIn = false;
         Notes.Clear();
         SelectedNotebook = null;
         Notebooks.Clear();
     }
 }
Beispiel #17
0
 public void ReadNotebooks()
 {
     using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
     {
         var notebooks = conn.Table <Notebook>().ToList();
         Notebooks.Clear();
         foreach (var notebook in notebooks)
         {
             Notebooks.Add(notebook);
         }
     }
 }
 public async void GetNotebooks()
 {
     try
     {
         var notebooks = (await Database.Read <Notebook>()).Where(n => n.UserId == App.UserId).ToList();
         Notebooks.Clear();
         foreach (var notebook in notebooks)
         {
             Notebooks.Add(notebook);
         }
     }
     catch (ArgumentNullException) { }
 }
Beispiel #19
0
 public void ReadNotebooks()
 {
     using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
     {
         //TODO: handle this exception (When a table of notebook does not exists)
         var notebooks = connection.Table <Notebook>().ToList();
         Notebooks.Clear();
         foreach (Notebook notebook in notebooks)
         {
             Notebooks.Add(notebook);
         }
         SelectedNotebook = Notebooks.FirstOrDefault();
     }
 }
Beispiel #20
0
        public void ReadNotebooks()
        {
            using (SQLite.SQLiteConnection cn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            {
                var notebooks = cn.Table <Notebook>().ToList();
                //TODO: pobieranie notatnikow dla zalogowanego usera

                Notebooks.Clear();
                foreach (var item in notebooks)
                {
                    Notebooks.Add(item);
                }
            }
        }
Beispiel #21
0
        public void ReadNoteBooks()
        {
            using (SQLiteConnection connection = new SQLiteConnection(DatabaseHelper.dbFile))
            {
                //var notebooks = connection.Table<NoteBook>().ToList();
                var notebooks = connection.Table <NoteBook>().Where(n => n.UserID == App.UserID).ToList();

                Notebooks.Clear();

                foreach (var noteBook in notebooks)
                {
                    Notebooks.Add(noteBook);
                }
            }
        }
Beispiel #22
0
        public void ReadNotebooks()
        {
            // get all Notebooks from the database
            using (SQLiteConnection connection = new SQLiteConnection(DatabaseHelper.dbFile))
            {
                connection.CreateTable <Notebook>();
                var notebooks = connection.Table <Notebook>().ToList();

                Notebooks.Clear();
                foreach (Notebook nb in notebooks)
                {
                    Notebooks.Add(nb);
                }
            }
        }
Beispiel #23
0
        public void ReadNotebooks()
        {
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            {
                int userId    = int.Parse(App.UserId);
                var notebooks = conn.Table <Notebook>().Where(nb => nb.UserId == userId).ToList();
                Notebooks.Clear();

                foreach (var notebook in notebooks)
                {
                    //notebook.IsEditing = false;
                    Notebooks.Add(notebook);
                }
            }
        }
Beispiel #24
0
        public void ReadNotebooks()
        {
            using (SQLiteConnection conn = new SQLiteConnection(DatabaseHelper.dbFile))
            {
                conn.CreateTable <Notebook>();
                var notebooks = conn.Table <Notebook>().ToList();

                //Clear so we do not re add everything every time
                Notebooks.Clear();

                foreach (Notebook notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
        }
        public void ReadNoteBooks()
        {
            using (SQLiteConnection conn = new SQLiteConnection(DatabaseHelper.dbFile))
            {
                conn.CreateTable <NoteBook>();

                //int userid = int.Parse(App.UserId);
                var notebooks = conn.Table <NoteBook>().ToList();
                Notebooks.Clear();
                if (notebooks != null)
                {
                    foreach (var notebook in notebooks)
                    {
                        Notebooks.Add(notebook);
                    }
                }
            }
        }
        private async Task OnSectionCreated(SectionCreated msg)
        {
            var notebooks = await _notebook.GetNotebooks();

            var selectedNotebook = Notebooks.Single(n => n.IsSelected);

            await DoOnUiDispatcherAsync(() =>
            {
                Notebooks.Clear();
                notebooks.ForEach(n =>
                {
                    if (n.Id == selectedNotebook.Id)
                    {
                        n.Select();
                    }
                    Notebooks.Add(n);
                });
            });
        }
        private void InitMainMenu()
        {
            var notebooks = Hub.Instance.Storage.GetNotebooks();
            var items     = ViewModelLocator.Instance.GetNotebookViewModels(notebooks);

            items.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal));

            if (!Hub.Instance.EncryptionManager.SecureNotesEnabled && items.Any())
            {
                InvokeOnCurrentDispatcher(() =>
                {
                    SelectedNotebook            = items[0];
                    SelectedNotebook.IsSelected = true;
                });
            }

            Notebooks.Clear();
            items.ForEach(Notebooks.Add);
        }
Beispiel #28
0
        private async void ReadNotebooks()
        {
            // NOTE: Bad handling of try catch
            try
            {
                var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync();

                Notebooks.Clear();

                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Beispiel #29
0
        public void ReadNotebooks()
        {
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            {
                conn.CreateTable <Notebook>();
                int  appUserId;
                bool appUserIdExists = int.TryParse(App.UserId, out appUserId);
                if (!appUserIdExists)
                {
                    appUserId = 0;
                }
                var notebooks = conn.Table <Notebook>().Where(n => n.UserId == appUserId).ToList();

                Notebooks.Clear();
                foreach (var notebook in notebooks)
                {
                    Notebooks.Add(notebook);
                }
            }
        }
Beispiel #30
0
        //đã check hết
        public void ReadNotebooks()
        {
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
            {
                try
                {
                    //truy cập vào database và gán notebooks 1 list các notebook
                    var notebooks = conn.Table <Notebook>().Where(n => n.UserId == App.UserID).ToList();
                    //mỗi khi chúng ta đọc notebooks thì sẽ không bị nhân đôi lên

                    Notebooks.Clear();
                    foreach (var notebook in notebooks)
                    {
                        Notebooks.Add(notebook);
                    }
                }
                catch
                {
                }
            }
        }