public async void Search(object sender, EventArgs args) { Application.Current.Properties["id"] = "Entered Picker"; Cover.IsVisible = true; await SearchButton.ScaleTo(0.95, 50, Easing.CubicOut); await SearchButton.ScaleTo(1, 50, Easing.CubicIn); bool state = true; var CityName = Application.Current.Properties["City"]; var HospitalName = Application.Current.Properties["Hospital"]; var SpecialtyName = Application.Current.Properties["Specialty"]; try { if (HospitalName.ToString() != "Choose Hospital" && SpecialtyName.ToString() != "Choose Specialty") { ListOfDoctors.Clear(); HttpClient client = new HttpClient(); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/EmployeeData?" + WebUtility.UrlEncode("where=" + JsonConvert.SerializeObject(new DataParserForEmployees() { Hospital = HospitalName.ToString(), Specialty = SpecialtyName.ToString() }))); message.Headers.Clear(); message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt"); message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC"); HttpResponseMessage response = await client.SendAsync(message); string content = await response.Content.ReadAsStringAsync(); DataToListForEmployees a = JsonConvert.DeserializeObject <DataToListForEmployees>(content); foreach (var item in a.GetStringList()) { ListOfDoctors.Add(item); } if (ListOfDoctors.Count == 0) { await DisplayAlert("Problem", " No Doctor in database", "ok"); Cover.IsVisible = false; } else { //loading.IsVisible = false; Cover.IsVisible = false; await Navigation.PushAsync(new ResultsC(ListOfDoctors, username)); } } else if (CityName.ToString() != "Choose City" && SpecialtyName.ToString() != "Choose Specialty") { ListOfDoctors.Clear(); HttpClient client = new HttpClient(); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/EmployeeData?" + WebUtility.UrlEncode("where=" + JsonConvert.SerializeObject(new DataParserForEmployees() { City = CityName.ToString(), Specialty = SpecialtyName.ToString() }))); message.Headers.Clear(); message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt"); message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC"); HttpResponseMessage response = await client.SendAsync(message); string content = await response.Content.ReadAsStringAsync(); DataToListForEmployees a = JsonConvert.DeserializeObject <DataToListForEmployees>(content); foreach (var item in a.GetStringList()) { ListOfDoctors.Add(item); } if (ListOfDoctors.Count == 0) { await DisplayAlert("Problem", " No Doctor in database", "ok"); Cover.IsVisible = false; } else { //loading.IsVisible = false; Cover.IsVisible = false; await Navigation.PushAsync(new ResultsC(ListOfDoctors, username)); } } else if (CityName.ToString() != "Choose City" && HospitalName.ToString() != "Choose Hospital") /////////// important for repeated hospitals in diffrent cities { ListOfDoctors.Clear(); HttpClient client = new HttpClient(); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/EmployeeData?" + WebUtility.UrlEncode("where=" + JsonConvert.SerializeObject(new DataParserForEmployees() { City = CityName.ToString(), Hospital = HospitalName.ToString() }))); message.Headers.Clear(); message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt"); message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC"); HttpResponseMessage response = await client.SendAsync(message); string content = await response.Content.ReadAsStringAsync(); DataToListForEmployees a = JsonConvert.DeserializeObject <DataToListForEmployees>(content); foreach (var item in a.GetStringList()) { ListOfDoctors.Add(item); } if (ListOfDoctors.Count == 0) { await DisplayAlert("Problem", " No Doctor in database", "ok"); Cover.IsVisible = false; } else { //loading.IsVisible = false; Cover.IsVisible = false; await Navigation.PushAsync(new ResultsC(ListOfDoctors, username)); } } else if (CityName.ToString() != "Choose City") { ListOfDoctors.Clear(); HttpClient client = new HttpClient(); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/EmployeeData?" + WebUtility.UrlEncode("where=" + JsonConvert.SerializeObject(new DataParserForEmployees() { City = CityName.ToString() }))); message.Headers.Clear(); message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt"); message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC"); HttpResponseMessage response = await client.SendAsync(message); string content = await response.Content.ReadAsStringAsync(); DataToListForEmployees a = JsonConvert.DeserializeObject <DataToListForEmployees>(content); foreach (var item in a.GetStringList()) { ListOfDoctors.Add(item); } if (ListOfDoctors.Count == 0) { await DisplayAlert("Problem", " No Doctor in database", "ok"); Cover.IsVisible = false; } else { //loading.IsVisible = false; Cover.IsVisible = false; await Navigation.PushAsync(new ResultsC(ListOfDoctors, username)); } } else if (HospitalName.ToString() != "Choose Hospital") { ListOfDoctors.Clear(); HttpClient client = new HttpClient(); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/EmployeeData?" + WebUtility.UrlEncode("where=" + JsonConvert.SerializeObject(new DataParserForEmployees() { Hospital = HospitalName.ToString() }))); message.Headers.Clear(); message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt"); message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC"); HttpResponseMessage response = await client.SendAsync(message); string content = await response.Content.ReadAsStringAsync(); DataToListForEmployees a = JsonConvert.DeserializeObject <DataToListForEmployees>(content); foreach (var item in a.GetStringList()) { ListOfDoctors.Add(item); } if (ListOfDoctors.Count == 0) { await DisplayAlert("Problem", " No Doctor in database", "ok"); Cover.IsVisible = false; } else { //loading.IsVisible = false; Cover.IsVisible = false; await Navigation.PushAsync(new ResultsC(ListOfDoctors, username)); } } else if (SpecialtyName.ToString() != "Choose Specialty") { ListOfDoctors.Clear(); HttpClient client = new HttpClient(); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/EmployeeData?" + WebUtility.UrlEncode("where=" + JsonConvert.SerializeObject(new DataParserForEmployees() { Specialty = SpecialtyName.ToString() }))); message.Headers.Clear(); message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt"); message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC"); HttpResponseMessage response = await client.SendAsync(message); string content = await response.Content.ReadAsStringAsync(); DataToListForEmployees a = JsonConvert.DeserializeObject <DataToListForEmployees>(content); foreach (var item in a.GetStringList()) { ListOfDoctors.Add(item); } if (ListOfDoctors.Count == 0) { await DisplayAlert("Problem", " No Doctor in database", "ok"); Cover.IsVisible = false; } else { //loading.IsVisible = false; Cover.IsVisible = false; await Navigation.PushAsync(new ResultsC(ListOfDoctors, username)); } } else { ListOfDoctors.Clear(); HttpClient client = new HttpClient(); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://api.parse.com/1/classes/EmployeeData?"); message.Headers.Clear(); message.Headers.Add("X-Parse-Application-Id", "2kWwje4PWZ980GmHQBk4EneY7DkENmlikDEZdwKt"); message.Headers.Add("X-Parse-REST-API-Key", "3cZnB4kNlPYCChLXEp90tjuBbioTBcycnkMtV9qC"); HttpResponseMessage response = await client.SendAsync(message); string content = await response.Content.ReadAsStringAsync(); DataToListForEmployees a = JsonConvert.DeserializeObject <DataToListForEmployees>(content); foreach (var item in a.GetStringList()) { ListOfDoctors.Add(item); } if (ListOfDoctors.Count == 0) { await DisplayAlert("Problem", " No Doctor in database", "ok"); Cover.IsVisible = false; } else { //loading.IsVisible = false; Cover.IsVisible = false; await Navigation.PushAsync(new ResultsC(ListOfDoctors, username)); } } } catch (Exception e) { state = false; } if (state == false) { await DisplayAlert("Problem", "Issue with connection", "ok"); Cover.IsVisible = false; state = true; } }