Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
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;
            }
        }
        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);
            }
        }
Ejemplo n.º 5
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;
            }
        }