private void BtnDelete_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { HeroConn conn = new HeroConn(); Task.Run(() => conn.Delete(this.hero)).Wait(); this.mainPage.GetHeroes(); }
private void BtnUpdate_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { HeroConn conn = new HeroConn(); this.hero.Name = this.tbName.Text; this.hero.Rating = Convert.ToInt32(this.tbRating.Text); Task.Run(() => conn.Update(this.hero)).Wait(); this.mainPage.GetHeroes(); }
private async void btnAdd_Tapped(object sender, TappedRoutedEventArgs e) { HeroConn heroConn = new HeroConn(); Hero hero = new Hero { Name = this.tbInputName.Text, Rating = Convert.ToInt32(this.tbInputRating.Text) }; await heroConn.Insert(hero); this.tbOutput.Text = String.Format("Hero {0} added!", hero.Name); // get new data and update UI GetHeroes(); }
// call the HeroConn method, populate heroList and also update the UI public void GetHeroes() { // create a new List heroList = new List <Hero>(); // and a new connection HeroConn conn = new HeroConn(); // get the data and add it to the heroList Task.Run(() => conn.Get()).Wait(); // clear all HeroItems from the StackPanel this.spHeroList.Children.Clear(); // and add new ones foreach (Hero h in heroList) { this.spHeroList.Children.Add(new HeroItem(h, this)); } }