private void GenerateReport() { BusyViewModel.ActiveAsync("... Generating ...") .Then(() => Items.ClearAsync(), Scheduler.Dispatcher.TPL) .Then(() => Service.GenerateAsync(Service.CreateRequest(ParameterViewModel)), Scheduler.Task.TPL) .Do(response => _response = response, Scheduler.Task.TPL) .Then(response => Service.GenerateDataViewModelsAsync(response), Scheduler.Task.TPL) .Do(dataViewModels => { foreach (var dataViewModel in dataViewModels) { Items.Add(dataViewModel); var supportActivationState = dataViewModel as ISupportActivationState; if (supportActivationState != null) { this.SyncViewModelActivationStates(supportActivationState).AddDisposable(Disposables); } } }, Scheduler.Dispatcher.TPL) .LogException(Log) .CatchAndHandle(x => StandardDialog.Error("Error", "Problem Generating Report"), Scheduler.Task.TPL) .Finally(() => { BusyViewModel.InActive(); IsExpanded = false; _exportToExcel.RaiseCanExecuteChanged(); }, Scheduler.Task.TPL); }
protected override Task OnInitialise() { return(BusyViewModel.ActiveAsync("Loading") .Then(() => _service.GetGendersAsync(), Scheduler.Task.TPL) .Do(genders => Genders.AddRangeAsync(genders), Scheduler.Dispatcher.TPL) .Finally(() => BusyViewModel.InActive(), Scheduler.Dispatcher.TPL)); }
private void Save() { BusyViewModel.ActiveAsync("... Saving Quote ...") .Then(() => _service.SaveQuoteAsync(Model), Scheduler.Task.TPL) .LogException(Log) .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem saving quote"), Scheduler.Task.TPL) .Finally(() => { BusyViewModel.InActive(); ClosingStrategy.Close(); }, Scheduler.Task.TPL); }
private void ExportToExcel() { BusyViewModel.ActiveAsync("... Exporting to Excel ...") .Do(() => Service.ExportToExcel(_response), Scheduler.Task.TPL) .LogException(Log) .CatchAndHandle(x => StandardDialog.Error("Error", "Problem Exporting to Excel"), Scheduler.Task.TPL) .Finally(() => { BusyViewModel.InActive(); IsExpanded = false; }, Scheduler.Task.TPL); }