public void SearchAPI() { // Execute a test search and ensure results are returned. BabySafeRx.OpenFda openFda = new BabySafeRx.OpenFda("https://api.fda.gov/drug/label.json"); // Simple IoC example. string searchString = "Topamax"; List<BabySafeRxData> babySafeData = openFda.callAPI(searchString); Assert.IsTrue(babySafeData.Count > 0); }
protected void searchButton_Click(object sender, ImageClickEventArgs e) { if (inputSearch.Text.Length > 0) { lblError.Visible = false; OpenFda openFda = new OpenFda("https://api.fda.gov/drug/label.json"); // Simple IoC example. // Perform the search on OpenFDA... List<BabySafeRxData> babySafeList = openFda.callAPI(inputSearch.Text); if (babySafeList.Count == 0) { lblError.Text = inputSearch.Text + " was not found"; lblError.Visible = true; } else { Session["babySafeData"] = babySafeList; Response.Redirect("drug-search.aspx?search=" + inputSearch.Text); } } }