public static async Task WaitingList(StackLayout Stack) { Device.BeginInvokeOnMainThread(delegate { Stack.Children.Clear(); }); try { String ResponseJson = await AppointmentModel.WaitingList("user/appointments/?id=" + Utilities.MedicID); var DecodedJson = JObject.Parse(ResponseJson); if ((int)DecodedJson["records"] > 0) { await Utilities.RunTask(delegate { foreach (var appointment in DecodedJson["appointments"]) { Status CurrentStatus = Status.Approved; switch ((int)appointment["status"]) { case -1: CurrentStatus = Status.Declined; break; case 0: CurrentStatus = Status.Waiting; break; } ; Device.BeginInvokeOnMainThread(delegate { Stack.Children.Add(WaitingRoomTemplate.WaitingTemplate02((int)appointment["user_id"], (int)appointment["id"], appointment["name"].ToString(), CurrentStatus, appointment["time"].ToString(), appointment["description"].ToString(), Utilities.Source("doc_anim.jpg", typeof(AppointmentController)), appointment["phone_number"].ToString())); }); } }); } else { Device.BeginInvokeOnMainThread(() => { Stack.Children.Add(new Label { Text = "No Patients in the waiting room.", Style = App.Current.Resources["_EmptyLabelTemplate"] as Style }); }); } } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "ok"); } }