private async Task ExecuteRemoteCommand(Func <ProxyClient, Task <bool> > remoteCommandAction) { try { if (!ValidateAppSettings()) { return; } await dialogsService.ShowLoading("Executing command...", async() => { var client = await lazyProxyClient.GetProxyClient(appSettings.RemoteAddress, appSettings.Port); var remoteCommandActionResult = await remoteCommandAction(client); if (remoteCommandActionResult) { UpdateConnectedStatus(true); } }); } catch (Exception exc) { UpdateConnectedStatus(false); await dialogsService.Error(exc.Message); } }
private void ShowLoading() { dialogsService.ShowLoading("Title", async() => { await Task.Delay(5000); dialogsService.Toast("Finished"); }, () => dialogsService.Toast("Cancelled")); }
private async Task LoadData() { try { _dialogsService.ShowLoading(); List <ActivityModel> result; if (_context.UseCloud) { var response = await _apiService.GetAllActivities(); result = response.Data; } else { result = await _localDatabaseService.GetAllActivities(); } ToDo = new ObservableCollection <ActivityItemViewModel>(); Doing = new ObservableCollection <ActivityItemViewModel>(); Done = new ObservableCollection <ActivityItemViewModel>(); foreach (var item in result) { switch ((ActivityState)item.State) { case Enumerations.ActivityState.ToDo: ToDo.Add(ViewModelHelper.Get(item)); break; case Enumerations.ActivityState.Doing: Doing.Add(ViewModelHelper.Get(item)); break; case Enumerations.ActivityState.Done: Done.Add(ViewModelHelper.Get(item)); break; default: break; } } } catch (Exception ex) { _dialogsService.ShowMessage("Error", "Ha ocurrido un error inesperado"); } finally { _dialogsService.HideLoading(); } }
private async Task Save() { try { _dialogsService.ShowLoading(); if (_context.UseCloud) { await SaveInCloud(); } else { await SaveInLocalDatabase(); } } catch (Exception) { _dialogsService.ShowMessage("Error", "Ha ocurrido un error, revise su conexión."); } finally { _dialogsService.HideLoading(); } }