Ejemplo n.º 1
0
        public async void GetHospital()
        {
            // here you fetch Data

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

            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();

                DataToListForHospital a = JsonConvert.DeserializeObject <DataToListForHospital>(content);
                foreach (var item in a.GetStringList())
                {
                    MyHospital.Add(item);
                    ListOfHospitals.Items.Add(item);
                }

                // listView.ItemsSource = MyList;
            }
            catch (Exception e1)
            {
            }
        }
Ejemplo n.º 2
0
        public async void GetHospitalWithCondition()
        {
            MyHospital.Clear();
            ListOfHospitals.Items.Clear();
            // here you fetch Data
            int                SelectedCity = ListOfCities.SelectedIndex;
            HttpClient         client       = new HttpClient();
            HttpRequestMessage message      = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/Hospital?" + WebUtility.UrlEncode("where=" + JsonConvert.SerializeObject(new DataParserForHospital()
            {
                City = MyCity[SelectedCity]
            })));

            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();

                DataToListForHospital a = JsonConvert.DeserializeObject <DataToListForHospital>(content);
                foreach (var item in a.GetStringList())
                {
                    MyHospital.Add(item);
                    ListOfHospitals.Items.Add(item);
                }
                Loading2.IsRunning = false;

                ListOfHospitals.IsVisible = true;
            }
            catch (Exception e1)
            {
            }
        }
Ejemplo n.º 3
0
        async void SearchHospital(object sender, EventArgs args)
        {
            MyHospital.Clear();
            await Hospital.ScaleTo(0.95, 50, Easing.CubicOut);

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

            HospitalLoad.IsVisible = true;
            Hospital.Text          = "";
            bool state = true;

            var HospitalName = Application.Current.Properties["Hospital"] as string;
            var CityName     = Application.Current.Properties["City"] as string;

            if (CityName != "Choose City")
            {                                              ////////////////////////////////     search hospitals with a specific City
                HttpClient client = new HttpClient();

                HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/Hospital?" + WebUtility.UrlEncode("where=" + JsonConvert.SerializeObject(new DataParserForEmployees()
                {
                    City = CityName
                })));
                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();

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

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

                    HospitalLoad.IsVisible = false;
                    Hospital.Text          = "Choose Hospital";
                }
                else
                {
                    await Navigation.PushAsync(new HospitalSearch(MyHospital));

                    HospitalLoad.IsVisible = false;
                    Hospital.Text          = "Choose Hospital";
                }
            }
            else          ////////////////////////////////     search hospitals without specific City
            {
                HttpClient client = new HttpClient();

                HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/Hospital?");
                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();

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

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

                    HospitalLoad.IsVisible = false;
                    Hospital.Text          = "Choose Hospital";
                }
                else
                {
                    await Navigation.PushAsync(new HospitalSearch(MyHospital));

                    HospitalLoad.IsVisible = false;
                    Hospital.Text          = "Choose Hospital";
                }
            }
        }