public IActionResult SurveyDatas() { APIHandler webHandler = new APIHandler(); SurveyDatas surveydatas = webHandler.GetSurveyDatas(); return(View(surveydatas)); }
public SurveyDatas GetSurveyDatas() { // string NATIONAL_PARK_API_PATH = BASE_URL + "/parks?limit=20"; string STATE_API_PATH = BASE_URL + "/state?"; string surveydataData = ""; SurveyDatas surveydatas = null; httpClient.BaseAddress = new Uri(STATE_API_PATH); // It can take a few requests to get back a prompt response, if the API has not received // calls in the recent past and the server has put the service on hibernation try { HttpResponseMessage response = httpClient.GetAsync(STATE_API_PATH).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { surveydataData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!surveydataData.Equals("")) { // JsonConvert is part of the NewtonSoft.Json Nuget package surveydatas = JsonConvert.DeserializeObject <SurveyDatas>(surveydataData); } } catch (Exception e) { // This is a useful place to insert a breakpoint and observe the error message Console.WriteLine(e.Message); } return(surveydatas); }
public IActionResult SurveyData(string reportName) { APIHandler webHandler = new APIHandler(); SurveyDatas surveydatas = webHandler.GetSurveyDatas(reportName); ViewBag.Reports = new APIHandler().GetReports(); return(View(surveydatas)); }
public IActionResult Chart() { APIHandler webHandler = new APIHandler(); ViewBag.dbSuccessChart = 0; SurveyDatas surveydatas = null; return(View("Charts", surveydatas)); }
/* * This method is used to generate line chart for the survey data */ public IActionResult Chart() { string report = "Government Payments"; ViewBag.dbSuccessChart = 0; SurveyDatas surveydatas = null; if (report != null) { HomeController webHandler = new HomeController(dbContext); surveydatas = webHandler.GetSurveyData(report); } return(View("Charts", surveydatas)); }
public IActionResult SurveyData(String test) { if (test == null) { test = "abc"; } string SURVEYDATA_API_PATH = BASE_URL + "surveydata?"; string surveyData = ""; string[] words = test.Split(' '); String report = ""; foreach (String word in words) { report = report + "+" + word; } //Change the report name into the url format by replacing spaces with + symbol SurveyDatas surveyDatas = null; SURVEYDATA_API_PATH = SURVEYDATA_API_PATH + "year=2015&report=" + report + "&"; httpClient.BaseAddress = new Uri(SURVEYDATA_API_PATH); // It can take a few requests to get back a prompt response, if the API has not received // calls in the recent past and the server has put the service on hibernation try { HttpResponseMessage response = httpClient.GetAsync(SURVEYDATA_API_PATH).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { surveyData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!surveyData.Equals("")) { // JsonConvert is part of the NewtonSoft.Json Nuget package surveyDatas = JsonConvert.DeserializeObject <SurveyDatas>(surveyData); } } catch (Exception e) { // This is a useful place to insert a breakpoint and observe the error message Console.WriteLine(e.Message); } return(View(surveyDatas)); }