Exemplo n.º 1
0
        private void RemoveGroupButton_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new ExpansesManagerContext())
            {
                if (TreeView1.SelectedItem == null)
                {
                    MessageBox.Show("Please select first.");
                    return;
                }
                //context.Groups.FirstOrDefault(g => g.Name == TreeView1.SelectedItem.ToString() && g.IsActive == true).IsActive = false;
                var group = context.Groups.FirstOrDefault(g => g.Name == TreeView1.SelectedItem.ToString() && g.IsActive == true);
                context.Groups.Remove(group);
                context.SaveChanges();
            }

            TreeViewItem newGroup = new TreeViewItem();

            newGroup.Name = TreeView1.SelectedItem.ToString();

            MainApp mApp = new MainApp();

            this.Close();
            mApp.ShowDialog();
        }