예제 #1
0
 public void ConvertApiDate()
 {
     OpenFda openFda = new OpenFda("https://api.fda.gov/food/enforcement.json");
       string testDateString = "20101225";  // API returns date in format YYYYMMDD
       DateTime testDate = openFda.convertApiDate(testDateString);
       Assert.IsTrue(testDate.Equals(new DateTime(2010, 12, 25, 0, 0, 0)));
 }
예제 #2
0
 protected void searchButton_Click(object sender, ImageClickEventArgs e)
 {
     if (inputSearch.Text.Length > 0 || cmbState.SelectedValue.Length > 0)
       {
     OpenFda openFda = new OpenFda("https://api.fda.gov/food/enforcement.json");  // Simple IoC example.
     // Perform the search on OpenFDA...
     List<RecallFoodAlertData> recallList = openFda.callAPI(inputSearch.Text, cmbState.SelectedValue);
     Session["recallList"] = recallList;
     displayResults();
       }
 }
예제 #3
0
        public void SearchAPI()
        {
            OpenFda openFda = new OpenFda("https://api.fda.gov/food/enforcement.json");  // Simple IoC example.

              // Search by Name and State
              string searchString = "Schnuck's";
              List<RecallFoodAlertData> recallData = openFda.callAPI(searchString, "MO");
              Assert.IsTrue(recallData.Count > 0);

              // Search by Name only, make sure that whitespace is trimmed
              recallData = openFda.callAPI(searchString, "  ");
              Assert.IsTrue(recallData.Count > 0);

              // Search by State only, make sure that whitespace is trimmed
              recallData = openFda.callAPI("  ", "MO");
              Assert.IsTrue(recallData.Count > 0);
        }
예제 #4
0
        protected void searchButton_Click(object sender, ImageClickEventArgs e)
        {
            if (inputSearch.Text.Length > 0 || cmbState.SelectedValue.Length > 0)
              {
            lblError.Visible = false;
            OpenFda openFda = new OpenFda("https://api.fda.gov/food/enforcement.json");  // Simple IoC example.

            // Perform the search on OpenFDA...
            List<RecallFoodAlertData> recallList = openFda.callAPI(inputSearch.Text, cmbState.SelectedValue);
            //if (recallList.Count == 0)
            //{
            //  lblError.Text = inputSearch.Text + " was not found";
            //  lblError.Visible = true;
            //}
            //else
            //{
              Session["recallList"] = recallList;
              Response.Redirect("Search.aspx?search=" + inputSearch.Text + "&state=" + cmbState.SelectedValue);
            //}
              }
        }