AddCoffee() public method

public AddCoffee ( bool atHome ) : Task
atHome bool
return Task
        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;
            }
        }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        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;
            }
        }