private void button1_Click(object sender, RoutedEventArgs e) { using (var db = new KanbanEntities()) { string listname = NewListBox.Text; var newie = db.Set<list>(); newie.Add(new list { Name = listname, CreatedDate = DateTime.Now }); db.SaveChanges(); NewListBox.Clear(); MessageBox.Show("You have added a new list."); } }
private void button2_Click(object sender, RoutedEventArgs e) { using (var db = new KanbanEntities()) { int cardlistid = 0 ; string cardname = CardNameBox.Text; string cardlist = CardListBox.Text; var newie = db.Set<Card>(); var listadd = db.lists.Where(u => u.Name == cardlist); foreach (var u in listadd) { cardlistid = u.ListId; } newie.Add(new Card { Text = cardname, CreatedDate = DateTime.Now, ListId = cardlistid }); db.SaveChanges(); NewListBox.Clear(); MessageBox.Show("You have added a new card."); } }