//Save public void SaveExecute(object param) { var v = new VNeuPflanzeW(); var vm = new VMNeuPflanze(); vm.Pflanz = GewaehltePflanze; vm.IsInEditMode = false; v.DataContext = vm; // view.DataContext = ViewModel v.ShowDialog(); if (v.DialogResult == true) { using (FloraEntities db = new FloraEntities()) { db.Entry(vm.Pflanz).State = EntityState.Modified; db.SaveChanges(); PropertyChanged(this, new PropertyChangedEventArgs("PlanzeImTopf")); } } }
//Neu public void NewExecute(object param) { var v = new VNeuPflanzeW(); var vm = new VMNeuPflanze(); vm.Pflanz = new Pflanzen(); vm.IsInEditMode = false; v.DataContext = vm; // view.DataContext = ViewModel v.ShowDialog(); if (v.DialogResult == true) { using (FloraEntities db = new FloraEntities()) { db.Pflanzens.Add(vm.Pflanz); db.SaveChanges(); PropertyChanged(this, new PropertyChangedEventArgs("PlanzeImTopf")); } } }