private async void pkrCity_SelectedIndexChanged(object sender, EventArgs e) { try { if (pkrCity.SelectedItem != null) { if (InternetConnection) { overlay.IsVisible = true; CityID objCityID = pkrCity.SelectedItem as CityID; int CityID = objCityID.id; int BundleID = objCheckupdata.data.corporate.meta.bundle_id; // objCheckupdata.data.patient.id 659 DCResponse objDC = await App.TodoManager.GetDCAHC(CityID, BundleID); pkrDC.ItemsSource = objDC.data; if (!EditMode) { overlay.IsVisible = false; } } else { var Retry = await DisplayAlert("No Connection", "Please Check Your Connection", "Retry", "Cancel"); if (Retry) { pkrCity_SelectedIndexChanged(sender, e); } } } } catch (Exception ex) { overlay.IsVisible = false; DependencyService.Get <IMessage>().LongAlert(); } }
public ActionResult Index() { HttpWebRequest WR = WebRequest.CreateHttp("https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1"); WR.UserAgent = ".NET Framework Test Client"; HttpWebResponse Response; try { Response = (HttpWebResponse)WR.GetResponse(); } catch (WebException e) { ViewBag.Error = "Exception"; ViewBag.ErrorDescription = e.Message; return(View()); } if (Response.StatusCode != HttpStatusCode.OK) { ViewBag.Error = Response.StatusCode; ViewBag.ErrorDescription = Response.StatusDescription; return(View()); } StreamReader reader = new StreamReader(Response.GetResponseStream()); string DeckData = reader.ReadToEnd(); JToken DeckID; try { JObject JsonData = JObject.Parse(DeckData); DeckID = JsonData["deck_id"]; ViewBag.DeckID = DeckID; } catch (Exception e) { ViewBag.Error = "JSON Issue"; ViewBag.ErrorDescription = e.Message; return(View()); } HttpWebRequest DC = WebRequest.CreateHttp("https://deckofcardsapi.com/api/deck/" + DeckID + "/draw/?count=5"); DC.UserAgent = ".Net Framework Test Client"; HttpWebResponse DCResponse; try { DCResponse = (HttpWebResponse)DC.GetResponse(); } catch (WebException e) { ViewBag.Error = "Exception"; ViewBag.ErrorDescription = e.Message; return(View()); } if (DCResponse.StatusCode != HttpStatusCode.OK) { ViewBag.Error = DCResponse.StatusCode; ViewBag.ErrorDescription = DCResponse.StatusDescription; return(View()); } StreamReader DCreader = new StreamReader(DCResponse.GetResponseStream()); string DCDeckData = DCreader.ReadToEnd(); try { JObject JsonData = JObject.Parse(DCDeckData); ViewBag.DeckID = JsonData["deck_id"]; ViewBag.Suit = JsonData["cards"]["suit"]; ViewBag.Value = JsonData["cards"]["value"]; ViewBag.Image = JsonData["cards"]["image"]; } catch (Exception e) { ViewBag.Error = "JSON Issue"; ViewBag.ErrorDescription = e.Message; return(View()); } return(View()); }