Esempio n. 1
0
        //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"));
                }
            }
        }
Esempio n. 2
0
        //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"));
                }
            }
        }