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); } } }
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; } }
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) { } }
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 }
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) { } }
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(); }
public void ReadNotebooks() { var notebooks = DatabaseHelper.Table <Notebook>(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } }
private void GetNotebooks() { var notebooks = DatabaseHelper.Read <Notebook>(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } }
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); } }
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); } }
private void GetNotebooks() { var notebooks = DatabaseHelper.Read <Notebook>(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); //Observable collection a ekleniyor } }
public void CreateNewNotebook() { Notebook notebook = new Notebook() { Name = "New notebook", Id = int.Parse(App.userID) }; DatabaseHelper.Insert(notebook); Notebooks.Add(notebook); }
public NotebookViewModel() { Notebook.Default.Notes.Add(Note.MyScriptNoteDefault); Notebooks.Add(Notebook.Default); Notebook.MyNotebookEn.Notes.Add(Note.ChinaNoteEn); Notebook.MyNotebookEn.Notes.Add(Note.FranceNoteEn); Notebooks.Add(Notebook.MyNotebookEn); Notebook.MyNotebookZh.Notes.Add(Note.ChinaNoteZh); Notebook.MyNotebookZh.Notes.Add(Note.FranceNoteZh); Notebooks.Add(Notebook.MyNotebookZh); }
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) { } }
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(); } }
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); } } }
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); } } }
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); } } }
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); } } }
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 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); } }
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); } } }
public void CreateIfNeeded() { if (newDb) { Database.EnsureCreated(); //Database.ExecuteSqlCommand(Database.GenerateCreateScript()); newDb = false; } if (Notebooks.Count() == 0) { Notebooks.Add(new Notebook { Name = "Archive" }); Notebooks.Add(new Notebook { Name = "Deleted" }); SaveChanges(); } }
//đã 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 { } } }
public void ReadNotebooks() { using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile)) { try { var notebooks = conn.Table <Notebook>().ToList(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } } catch (Exception ex) { if (ex.Message.Contains("no such table: Notebook")) { conn.CreateTable <Notebook>(); } } } }
public async void ReadNotebooks() { //using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile)) //{ // conn.CreateTable<Notebook>(); // var notebooks = conn.Table<Notebook>().ToList(); // Notebooks.Clear(); // foreach (var notebook in notebooks) // { // Notebooks.Add(notebook); // } //} var notebooks = await DatabaseHelper.Read <Notebook>(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } }