Example #1
0
        public async void GetMethod()
        {
            Plants.Clear();

            //var plants = await DataStore.GetItemsAsync(true);
            var clientget = new HttpClient();
            var uri2      = "http://192.168.87.171:3000/measurements";

            try
            {
                var response2 = await clientget.GetAsync(uri2);

                if (response2.IsSuccessStatusCode)
                {
                    string content = await response2.Content.ReadAsStringAsync();

                    Console.WriteLine(content);
                    List <Plant> plantie = JsonConvert.DeserializeObject <List <Plant> >(content);

                    foreach (var item in plantie)
                    {
                        Plant planget = new Plant {
                            PlantID = item.plantID, Temperature = item.temperature, AirHumidity = item.airHumidity, TempWarning = item.tempWarning, DrySoil = item.drySoil, DateTime = item.dateTime, ImageSource = item.imageSource, ColorBackground = item.colorBackground
                        };


                        Plants.Add(planget);
                    }
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("Error");
            }
        }
        async Task ExecuteLoadPlantsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Plants.Clear();
                var items = await DataStore.GetPlantsAsync(true);

                Plants.ReplaceRange(items);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                // MessageDialog.SendMessage("Unable to load items.", "Error");
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #3
0
        private async void GetPlants()
        {
            if (Plants != null)
            {
                Plants.Clear();
            }

            var plants = await _plantManager.GetPlants();

            Plants = new ObservableCollection <Plant>(plants);
        }
Example #4
0
        async Task RefreshPlants()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            Plants.Clear();
            List <Plant> plants = await App.PlantService.GetAllPlantsAsync();

            foreach (var plant in plants)
            {
                await LoadPlantPhoto(plant);

                Plants.Add(plant);
            }
            IsBusy = false;
        }
Example #5
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Plants.Clear();
                var plants = await DataStore.GetItemsAsync(true);

                foreach (var plant in plants)
                {
                    Plants.Add(plant);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #6
0
 public void RefreshPlants(List <Plant> plants)
 {
     Plants.Clear();
     Plants = plants;
 }