Mvvm Pattern erweitert

This commit is contained in:
Husky
2020-02-21 08:50:00 +01:00
parent 183646b4da
commit 5798fc6108
7 changed files with 51 additions and 52 deletions

View File

@@ -23,40 +23,15 @@ namespace KanSan.UI
/// </summary>
public partial class WindowBaustelleEdit : Window
{
private UnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
private Baustelle bs = null;
public WindowBaustelleEdit(Baustelle baustelle)
public WindowBaustelleEdit()
{
InitializeComponent();
if (baustelle == null) throw new ArgumentNullException("baustelle");
bs = baustelle;
BaustelleViewModel model = new BaustelleViewModel(bs);
model.PropertyChanged += Model_PropertyChanged;
this.DataContext = model;
this.DataContext = new BaustelleViewModel();
}
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();
}
}
}