private void UserCreateUC_UserCreated(object sender, EventArgs e) { User user = (e as UserEventArgs).User; this.users.Add(user); using (var db = new GriffonWpfContext()) { db.Users.Add(user); db.SaveChanges(); } }
private void RemoveItem_HaveToRemoved(object sender, EventArgs e) { User user = (sender as RemoveItemCommand).ToRemoved as User; this.users.Remove(user); using (var db = new GriffonWpfContext()) { db.Entry(user).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }
private void LoadItems() { //this.currentPage.TxtB1.Text = "Bonjour"; using (var db = new GriffonWpfContext()) { foreach (var item in db.Users.ToList()) { users.Add(item); } } this.currentPage.listViewUsers.ItemsSource = users; this.RemoveItem = new RemoveItemCommand(); }