示例#1
0
        public async void GetSpecialty()
        {
            // here you fetch Data

            HttpClient         client  = new HttpClient();
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/Specialty?");

            message.Headers.Clear();
            message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt");
            message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC");

            try
            {
                HttpResponseMessage response = await client.SendAsync(message);

                string content = await response.Content.ReadAsStringAsync();

                DataToListForSpecialty a = JsonConvert.DeserializeObject <DataToListForSpecialty>(content);
                foreach (var item in a.GetStringList())
                {
                    MySpecialty.Add(item);
                    ListOfSpecialties.Items.Add(item);
                }
            }
            catch (Exception e1)
            {
            }
        }
示例#2
0
        async void SearchSpecialty(object sender, EventArgs args)
        {
            await Specialty.ScaleTo(0.95, 50, Easing.CubicOut);

            await Specialty.ScaleTo(1, 50, Easing.CubicIn);

            SpecialtyLoad.IsVisible = true;
            Specialty.Text          = "";
            bool               state   = true;
            HttpClient         client  = new HttpClient();
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/Specialty?");

            message.Headers.Clear();
            message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt");
            message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC");

            try
            {
                HttpResponseMessage response = await client.SendAsync(message);

                string content = await response.Content.ReadAsStringAsync();

                DataToListForSpecialty a = JsonConvert.DeserializeObject <DataToListForSpecialty>(content);
                foreach (var item in a.GetStringList())
                {
                    MySpecialty.Add(item);
                }


                // listView.ItemsSource = MyList;
            }
            catch (Exception e1)
            {
                state = false;
            }
            if (state == false)
            {
                await DisplayAlert("Problem", "No internet connection", "ok");

                SpecialtyLoad.IsVisible = false;
                Specialty.Text          = "Choose Specialty";
            }
            else
            {
                await Navigation.PushAsync(new SpecialtySearch(MySpecialty));

                SpecialtyLoad.IsVisible = false;
                Specialty.Text          = "Choose Specialty";
            }
        }