private void DoEditCmd(object parameter) { if (parameter != null) { Cottager cottager = (Cottager)parameter; Garden garden = cottager.Garden; EditCottagerView editView = new EditCottagerView(); EditCottagerViewModel editViewModel = new EditCottagerViewModel(cottager, editView); editView.DataContext = editViewModel; editView.ShowDialog(); if (editView.DialogResult.HasValue && editView.DialogResult.Value) { _PumpStationBL.EditCottager(cottager); _UnitOfWork.Commit(); SelectedCottager = cottager; RefreshList(_selectedMonthId); } else { _UnitOfWork.GardenDAO.UndoChange(garden); _UnitOfWork.CottagerDAO.UndoChange(cottager); SelectedCottager = cottager; RefreshList(_selectedMonthId); } } }
private void DoAddCmd() { Cottager cottager = new Cottager(); Garden newGarden = new Garden(); cottager.Garden = newGarden; EditCottagerView editView = new EditCottagerView(); EditCottagerViewModel editViewModel = new EditCottagerViewModel(cottager, editView); editView.DataContext = editViewModel; editView.ShowDialog(); if (editView.DialogResult.HasValue && editView.DialogResult.Value) { cottager.MonthId = _selectedMonthId; _PumpStationBL.CreateCottager(cottager, newGarden); _UnitOfWork.Commit(); RefreshList(_selectedMonthId); } }
public EditCottagerViewModel(Cottager Cottager, EditCottagerView frame) { _Cottager = Cottager; _instanceWindow = frame; }