private async void ModifyClick(object sender, RoutedEventArgs e) { if (grid.SelectedItem == null) { MessageBox.Show("Select a record!"); return; } AddPeople addPeople = new AddPeople(DialogTypes.Modify); People people = grid.SelectedItem as People; addPeople.nameBox.Text = people.Name; addPeople.languageBox.Text = people.Language; addPeople.Img = people.Pic; if (addPeople.ShowDialog() == true) { people.Name = addPeople.nameBox.Text; people.Language = addPeople.languageBox.Text; people.Pic = addPeople.Img; using (PeopleContext db = new PeopleContext()) { db.Entry(people).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); } } }
private async void AddClick(object sender, RoutedEventArgs e) { AddPeople addPeople = new AddPeople(DialogTypes.Add); if (addPeople.ShowDialog() == true) { People people = new People { Name = addPeople.nameBox.Text, Language = addPeople.languageBox.Text, Pic = addPeople.Img }; await Task.Run(() => AddData(people)); } ShowDataAsync(); }