private void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e) { var item = treeView.SelectedItem; if (item is DataAccess.Table) { var popup = new NewTable(); Table table; if (popup.ShowDialog().GetValueOrDefault()) { table = popup.Table; } else { return; } _context.Tables.Add(table); } else if (item is DataAccess.Stack) { var popup = new NewStack(((DataAccess.Stack)item).TableID); Stack stack; if (popup.ShowDialog().GetValueOrDefault()) { stack = popup.Stack; } else { return; } ((DataAccess.Stack)item).Table.Stacks.Add(stack); //_context.Stacks.Add(stack); } else if (item is DataAccess.Book) { var popup = new NewBook(((DataAccess.Book)item).StackID); Book book; if (popup.ShowDialog().GetValueOrDefault()) { book = popup.Book; } else { return; } ((DataAccess.Book)item).Stack.Books.Add(book); } _context.SaveChanges(); treeView.Items.Refresh(); treeView.UpdateLayout(); }
private void NewTableCommand_Executed(object sender, ExecutedRoutedEventArgs e) { var popup = new NewTable(); Table table; if (popup.ShowDialog().GetValueOrDefault()) { table = popup.Table; } else { return; } _context.Tables.Add(table); _context.SaveChanges(); treeView.Items.Refresh(); treeView.UpdateLayout(); }