protected override async void OnAppearing() { base.OnAppearing(); #region Reading data from local database (Sqlite) /* * using (SQLiteConnection conn=new SQLiteConnection(App.DatabaseLocation)) * { * //If table is not exists would be created * //We can go to History page before insert any records * conn.CreateTable<Post>(); * * var posts = conn.Table<Post>().ToList(); * * postListView.ItemsSource = posts; * } */ #endregion Reading data from local database (Sqlite) await viewModel.UpdatePosts(); // Synchronize local andcloud database await AzureAppServiceHelper.SyncAsync(); }
protected override void OnAppearing() { base.OnAppearing(); //var message = "You in History page"; //DependencyService.Get<Imessage>().shortTime(message); //using (SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation)) //{ // conn.CreateTable<Post>(); // var posts = conn.Table<Post>().ToList(); // postlv.ItemsSource = posts; //} //var messagea = "We Getting Your Details"; //DependencyService.Get<Imessage>().shortTime(messagea); //var posts = await App.MobileService.GetTable<Post>().Where(p => p.UserId == App.users.Id).ToListAsync(); //viewModel.Posts.Clear(); //var posts = await Post.Read(); //foreach (var post in posts) // viewModel.Posts.Add(post); viewModel.UpdatePosts(); }
protected override async void OnAppearing() { base.OnAppearing(); viewModel.UpdatePosts(); await AzureAppServiceHelper.SyncAsync(); }
// Implementing OnAppearing so as to refresh the data on the page whenever navigated back-to //protected override async void OnAppearing() protected override void OnAppearing() { base.OnAppearing(); /* * using (SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation)) // use previously established location * // Since SQLiteConnection (qv) is implementing IDisposable, we can, with a 'using' statement, * // safely leave out connection.Close call as Dispose will be automatically called * * { * conn.CreateTable<Post>(); // create table (only) if non-existent * var posts = conn.Table<Post>().ToList(); // get list of Post objects (ie records) * * postListView.ItemsSource = posts; // set data context of ListView in xaml file (binding specified in xaml) * * // conn.Close(); // NB remembering to close connection! - not needed if 'using' SQLiteConnection * } // end of 'using' statement block */ // From 11-89 onwards, reading from Azure database not from local SQLite /* * //var posts = await App.MobileService.GetTable<Post>().Where(p => p.UserId == App.user.Id).ToListAsync(); * * viewModel.Posts.Clear(); // elements may already exist in list - clear list before fresh fetch from db * * var posts = await Post.Read(); // Read posts for current user in App - refactored 12-95 for MVVM * foreach (var post in posts) * { * viewModel.Posts.Add(post); // build up code-behind list of posts * } * // Itemsource of ListView for ObervableList set in XAML * //postListView.ItemsSource = posts; // REMmed out in 12-110 */ viewModel.UpdatePosts(); // update the list of posts in the view NB Ctrl. 12-110 }
protected async override void OnAppearing() { base.OnAppearing(); await viewModel.UpdatePosts(); // viewModel.IsAttending = await viewModel.PostAttend(); }
protected async override void OnAppearing() { try { base.OnAppearing(); await ViewModel.UpdatePosts(); await AzureAppServiceHelper.SyncAsync(); } catch (System.Exception ex) { } }
protected override async void OnAppearing() { base.OnAppearing(); //using (SQLiteConnection conn = new SQLiteConnection(App.DataBaseLocation)) //{ // conn.CreateTable<Post>(); // var posts = conn.Table<Post>().ToList(); // historyListView.ItemsSource = posts; //} await historyVM.UpdatePosts(); await AzureAppServiceHelper.SyncAsync(); }
protected override async void OnAppearing() { base.OnAppearing(); viewModel.UpdatePosts(); await AzureAppServiceHelper.SyncAsync(); //postListView.ItemsSource = posts; }
//ANTIGUO CON CLOSE ////Metodo que hace override al aprecer el Tab ////Lo usamos para leer de la base lo que sea que deba mostrarse en este tab //protected override void OnAppearing() //{ // base.OnAppearing();//No borrar // //coneción a la base // SQLiteConnection db = new SQLiteConnection(App.DbLocation); // //Creación de tabla (si ya existe la pasa por alto) // db.CreateTable<Post>(); // //Guardar resultados toList() // var post= db.Table<Post>().ToList(); // //Cerramos conexión // db.Close(); //} #endregion protected override async void OnAppearing() { base.OnAppearing(); //coneción a la base SQLite //using (SQLiteConnection db = new SQLiteConnection(App.DbLocation)) //{ // //Creación de tabla (si ya existe la pasa por alto) // db.CreateTable<Post>(); // //Guardar resultados toList() // var post = db.Table<Post>().ToList(); // //Pasamos la lista aun objeto ListView // PostListView.ItemsSource = post; //} viewModel.UpdatePosts(); //Refrescamos local y luego en nube await AzureAppServiceHelper.SyncAsync(); //PostListView.ItemsSource = posts; }
protected override void OnAppearing() { base.OnAppearing(); viewModel.UpdatePosts(); //Azure Function //var posts = await Post.Read(); //postListView.ItemsSource = posts; //Old Code //var posts = await App.MobileService.GetTable<Post>().Where(post => post.userId == App.currentUser.Id).ToListAsync(); //postListView.ItemsSource = posts; //SQLite Function //SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation); //conn.CreateTable<Post>(); //var posts = conn.Table<Post>().ToList(); //postListView.ItemsSource = posts; }
protected override void OnAppearing() { base.OnAppearing(); //using (SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation)) //{ // conn.CreateTable<Post>(); // var posts = conn.Table<Post>().ToList(); // postListView.ItemsSource = posts; //} //var posts = await App.MobileService.GetTable<Post>().Where(p => p.UserId == App.user.id).ToListAsync(); //var posts = await Post.Read(); //postListView.ItemsSource = posts; //viewModel.Posts.Clear(); // to keep on adding elements //var posts = await Post.Read(); //foreach (var post in posts) // viewModel.Posts.Add(post); viewModel.UpdatePosts(); }
protected override void OnAppearing() { base.OnAppearing(); viewModel.UpdatePosts(); }