コード例 #1
0
ファイル: CurePage.xaml.cs プロジェクト: dm1trykrylov/Sadovod
        private async void GetSymptoms(string plant)
        {
            var url = $"{symptURL}";
            var obj = new { name = plant };

            using (var client = new HttpClient())
            {
                var payload  = JsonConvert.SerializeObject(obj);
                var content  = new StringContent(payload, Encoding.UTF8, @"application/json");
                var response = await client.PostAsync(url, content);

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    symptList = Unwrap(result);
                    //SymptomListTxt.Text += result;
                    int count = 1;
                    foreach (string sympt in symptList.Symptoms)
                    {
                        SymptomListTxt.Text += $@"{count++} {sympt}";
                    }
                }
                else
                {
                    await DisplayAlert("Plant search", "Unknown plant", "OK");
                }
            }
        }
コード例 #2
0
ファイル: CurePage.xaml.cs プロジェクト: dm1trykrylov/Sadovod
        private SymptomsList Unwrap(string result)
        {
            result.Replace("[", String.Empty).Replace("]", String.Empty).Replace("{", String.Empty).Replace("}", String.Empty);
            SymptomsList list = new SymptomsList();

            list.Symptoms = result.Split(',');
            return(list);
        }