using KanSan.Base; using KanSan.Base.Models; using KanSan.ViewModel; using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace KanSan.UI { /// /// Interaktionslogik für FRMBaustelle.xaml /// public partial class WindowBaustelleEdit : Window { private UnitOfWork unitOfWork = new UnitOfWork(new KanSanContext()); private Baustelle bs = null; public WindowBaustelleEdit(Baustelle baustelle) { InitializeComponent(); if (baustelle == null) throw new ArgumentNullException("baustelle"); bs = baustelle; BaustelleViewModel model = new BaustelleViewModel(bs); model.PropertyChanged += Model_PropertyChanged; this.DataContext = model; } private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e) { BaustelleViewModel baustelleViewModel = (BaustelleViewModel)sender; bs.Ort = baustelleViewModel.Ort; bs.Projektnummer = baustelleViewModel.Projektnummer; bs.Strasse = baustelleViewModel.Strasse; unitOfWork.BaustellenRepository.Update(bs); //Debugger.Break(); } private void Window_Closed(object sender, EventArgs e) { unitOfWork.Commit(); } } }