public StaffListPageViewModel(INavigationService navigationService, Realm realm, TNaviParams naviparams) : base(navigationService) { _realm = realm; AddCommand = new DelegateCommand(async() => { naviparams.Set(_realm.BeginWrite()); naviparams.Set(_realm.CreateObject("TStaff", null)); await NavigationService.NavigateAsync("StaffEditPage"); }); EditCommand = new Command <TStaff>(async(staff) => { naviparams.Set(_realm.BeginWrite()); naviparams.Set(staff); await NavigationService.NavigateAsync("StaffEditPage"); }); DeleteCommand = new Command <TStaff>(DeleteStaff); Staffs = _realm.All <TStaff>() as IEnumerable <TStaff>; }
public StaffEditPageViewModel(INavigationService navigationService, Realm realm, TNaviParams naviparams) : base(navigationService) { _realm = realm; _transaction = naviparams.Get <Transaction>(); Staff = naviparams.Get <TStaff>(); SaveCommand = new DelegateCommand(async() => { // コミットして前画面に戻る _transaction.Commit(); await NavigationService.GoBackAsync(); }); CancelCommand = new DelegateCommand(async() => { // ロールバックして前画面に戻る _transaction.Rollback(); await NavigationService.GoBackAsync(); }); }