GetCoffees() public method

public GetCoffees ( ) : Task>
return Task>
        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;
            }
        }
Example #2
0
        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;
            }
        }
Example #3
0
        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;
            }
        }