private ReactiveCommand GetCommandRemoveActSelectionOfProbeDepartment(IObservable <bool> canExecute = null) { var command = new ReactiveCommand(canExecute); command.RegisterAsync( _ => _messenger.AskToObservable( "Удалить?", MessageBoxButton.YesNo, result => { if (result == MessageBoxResult.Yes) { var removingItem = SelectedActSelectionOfProbeDepartment; if (removingItem == null) { return; } RemoveActSelectionOfProbeDepartment(removingItem.Rn); Application.Current.Dispatcher.Invoke(() => { SelectedActSelectionOfProbe.ActSelectionOfProbeDepartments.Remove(removingItem); }); } })).Subscribe(); command.ThrownExceptions.Subscribe(OnError); command.IsExecuting.Subscribe(isExecuting => IsBusy = isExecuting); return(command); }
private ReactiveCommand GetCommandRemovePlanReceiptOrder(IObservable <bool> canExecute = null) { var command = new ReactiveCommand(canExecute); command.RegisterAsync(_ => _messenger.AskToObservable( "Удалить?", MessageBoxButton.YesNo, result => { if (result == MessageBoxResult.Yes) { PlanReceiptOrderLiteDto removingItem = SelectedPlanReceiptOrder; if (removingItem == null) { return; } RemovePlanReceiptOrder(removingItem.Rn); PlanReceiptOrderFilterViewModel.Result.Remove(removingItem); } })).Subscribe(); command.ThrownExceptions.Subscribe(OnError); command.IsExecuting.Subscribe(isExecuting => IsBusy = isExecuting); return(command); }