public void EditExecute(object param) { var v = new BearbeiteAutomatenCTL(); var vm = new BearbeiteAddVMODELAutomat(); vm.Auto = SelectedAutomat; vm.IsInEditMode = true; v.DataContext = vm; v.ShowDialog(); if (v.DialogResult == true) { using (SnackEmDBEntities db = new SnackEmDBEntities()) { db.Entry(vm.Auto).State = EntityState.Modified; db.SaveChanges(); PropertyChanged(this, new PropertyChangedEventArgs("AlleAutomaten")); } } }
public void NewExecute(object param) { if (SelectedAutomat != null) { var v = new BearbeiteAutomatenCTL(); var vm = new BearbeiteAddVMODELAutomat(); vm.Auto = new AUTOMATEN(); vm.IsInEditMode = false; v.DataContext = vm; v.ShowDialog(); if (v.DialogResult == true) { using (SnackEmDBEntities db = new SnackEmDBEntities()) { db.AUTOMATENs.Add(vm.Auto); db.SaveChanges(); PropertyChanged(this, new PropertyChangedEventArgs("AlleAutomaten")); } } } }
public void NewExecuteAuto(object param) { // New Button was pressed if (SelectedStandort != null) { var v = new BearbeiteAutomatenCTL(); var vm = new BearbeiteAddVMODELAutomat(); vm.Auto = new AUTOMATEN { A_S_ID = SelectedStandort.S_ID }; vm.IsInEditMode = false; v.DataContext = vm; // view.DataContext = ViewModel v.ShowDialog(); if (v.DialogResult == true) // speichern { using (SnackEmDBEntities db = new SnackEmDBEntities()) { // die stunden Instanz in den OR Mapper db.AUTOMATENs.Add(vm.Auto); db.SaveChanges(); PropertyChanged(this, new PropertyChangedEventArgs("AlleAutomaten")); } } } }