/// <summary> /// Initialize Instance. /// </summary> /// <param name="navigationService"></param> /// <param name="editReport"></param> public ReportPageViewModel(INavigationService navigationService, IEditReport editReport) { _navigationService = navigationService; _editReport = editReport; Name = editReport.ToReactivePropertyAsSynchronized(x => x.Name); Date = editReport.ToReactivePropertyAsSynchronized(x => x.Date); NavigateExpenseSelectionCommand = new ReactiveCommand(); NavigateExpenseSelectionCommand.Subscribe(_ => { _navigationService.NavigateAsync("ExpenseSelectionPage"); }); SaveReportCommand = new AsyncReactiveCommand(); SaveReportCommand.Subscribe(async _ => { await _editReport.SaveAsync(); await _navigationService.GoBackAsync(); }); }
/// <summary> /// Initialize Instance. /// </summary> /// <param name="navigationService"></param> /// <param name="editReport"></param> public ReportPageViewModel(INavigationService navigationService, IEditReport editReport) { _navigationService = navigationService; _editReport = editReport; Name = editReport.ToReactivePropertyAsSynchronized(x => x.Name); Date = editReport.ToReactivePropertyAsSynchronized(x => x.Date); InitializeCommand = new DelegateCommand(() => { Expenses = editReport.SelectableExpenses.Where(x => x.IsSelected); }); NavigateExpenseSelectionCommand = new DelegateCommand(() => { _navigationService.NavigateAsync("ExpenseSelectionPage"); }); SaveReportCommand = DelegateCommand.FromAsyncHandler(async() => { await _editReport.SaveAsync(); await _navigationService.GoBackAsync(); }); }
public ExpenseSelectionPageViewModel(IEditReport editReport) { Expenses = editReport.SelectableExpenses.ToReadOnlyReactiveCollection(); }