async Task ExecuteLoadCoffeesCommandAsync() { if (IsBusy || !(await LoginAsync())) { return; } try { LoadingMessage = "Loading Coffees..."; IsBusy = true; var coffees = await azureService.GetCoffees(); Coffees.ReplaceRange(coffees); SortCoffees(); } catch (Exception ex) { Debug.WriteLine("OH NO!" + ex); await Application.Current.MainPage.DisplayAlert("Sync Error", "Unable to sync coffees, you may be offline", "OK"); } finally { IsBusy = false; } }
async Task ExecuteLoadCoffeesCommandAsync() { if (IsBusy) { return; } try { LoadingMessage = "Loading Coffees..."; IsBusy = true; var coffees = await azureService.GetCoffees(); Coffees.ReplaceRange(coffees); SortCoffees(); } catch (Exception ex) { Debug.WriteLine("OH NO!" + ex); MessagingService.Current.SendMessage <MessagingServiceAlert>("message", new MessagingServiceAlert { Cancel = "OK", Message = "Unable to sync coffees, you may be offline", Title = "Coffee sync Error" }); } finally { IsBusy = false; } }
async Task ExecuteLoadCoffeesCommandAsync() { if (IsBusy) { return; } try { if (!Settings.IsLoggedIn) { await azureService.Initialize(); var user = await DependencyService.Get <IAuthentication>().LoginAsync(azureService.MobileService, MobileServiceAuthenticationProvider.MicrosoftAccount); if (user == null) { return; } } LoadingMessage = "Loading Coffees..."; IsBusy = true; var coffees = await azureService.GetCoffees(); Coffees.ReplaceRange(coffees); SortCoffees(); } catch (Exception ex) { Debug.WriteLine("OH NO!" + ex); MessagingService.Current.SendMessage <MessagingServiceAlert>("message", new MessagingServiceAlert { Cancel = "OK", Message = "Unable to sync coffees, you may be offline", Title = "Coffee sync Error" }); } finally { IsBusy = false; } }