Пример #1
0
        private void addCity(object sender, RoutedEventArgs e)
        {
            var city = new City();
            AddEditCityWindow addEditCityWindow = new AddEditCityWindow(city);
            var result = addEditCityWindow.ShowDialog();

            if (result == true)
            {
                context.Cities.Add(city);
                cities.Add(city);
                context.Save();
                addEditCityWindow.Close();
            }
        }
Пример #2
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            var city = viewCityDataGrid.SelectedItem as City;

            if (city != null)
            {
                AddEditCityWindow addEditCityWindow = new AddEditCityWindow(city);
                var result = addEditCityWindow.ShowDialog();
                if (result == true)
                {
                    this.DialogResult = true;
                    context.Save();
                    addEditCityWindow.Close();
                }
                else
                {
                    viewCityDataGrid.DataContext = null;
                    viewCityDataGrid.DataContext = cities;
                }
            }
        }