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 ExecuteAddCoffeeCommandAsync() { if (IsBusy || !(await LoginAsync())) { return; } try { LoadingMessage = "Adding Coffee..."; IsBusy = true; var coffee = await azureService.AddCoffee(AtHome); Coffees.Add(coffee); SortCoffees(); } catch (Exception ex) { Debug.WriteLine("OH NO!" + ex); } finally { LoadingMessage = string.Empty; IsBusy = false; } }
async Task ExecuteAddCoffeesCommandAsync() { if (IsBusy) { return; } try { IsBusy = true; //Add a Coffee var coffee = await azureService.AddCoffee(); Coffees.Add(coffee); } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { IsBusy = false; } }
async Task ExecuteLoadCoffeesCommandAsync() { if (IsBusy) { return; } try { IsBusy = true; //Get all here ! var coffees = await azureService.GetCoffees(); Coffees.ReplaceRange(coffees); } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { IsBusy = false; } }
async Task ExecuteAddCoffeeCommandAsync() { if (IsBusy) { return; } try { LoadingMessage = "Adding Coffee..."; IsBusy = true; Xamarin.Insights.Track("CoffeeAdded"); var coffee = await azureService.AddCoffee(AtHome); Coffees.Add(coffee); SortCoffees(); } catch (Exception ex) { Debug.WriteLine("OH NO!" + ex); //This is okay because we can Xamarin.Insights.Report(ex); } 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; } }
private void GetCoffeeFiles() { string[] files = Directory.GetFiles(path); foreach (var file in files) { CoffeeModel coffeeJson = JsonSerializer.Deserialize <CoffeeModel>(System.IO.File.ReadAllText(file)); Coffees.Add(coffeeJson); } }
async Task ExecuteAddCoffeeCommandAsync() { 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 = "Adding Coffee..."; IsBusy = true; var coffees = await azureService.GetCoffees(); Coffees.ReplaceRange(coffees); SortCoffees(); } else { LoadingMessage = "Adding Coffee..."; IsBusy = true; } Xamarin.Insights.Track("CoffeeAdded"); var coffee = await azureService.AddCoffee(AtHome); Coffees.Add(coffee); SortCoffees(); } catch (Exception ex) { Debug.WriteLine("OH NO!" + ex); //This is okay because we can Xamarin.Insights.Report(ex); } 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; } }