public async Task <ActionResult> GetMaxViewLogsInitialLoad(string id) { MaxViewLogViewModel maxViewLogViewModel = new MaxViewLogViewModel(); maxViewLogViewModel.MaxViewLogs = new List <MaxViewLog>(); using (var client = new HttpClient()) { string uri = WebAPI + "MaxviewTotal?"; uri += "signalId=" + id; //HTTP GET var responseTask = client.GetAsync(uri); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { string data = await result.Content.ReadAsStringAsync(); //use JavaScriptSerializer from System.Web.Script.Serialization JavaScriptSerializer JSserializer = new JavaScriptSerializer(); //deserialize to your class maxViewLogViewModel.TotalNumber = Convert.ToInt32(data); } else //web api sent error response { return(Content("Server error. Please contact administrator.")); } } return(PartialView("_MaxViewLog", maxViewLogViewModel)); }
public async Task <ActionResult> GetMaxViewLogsResult(string id, int?pageNumber) { MaxViewLogViewModel maxViewLogViewModel = new MaxViewLogViewModel(); using (var client = new HttpClient()) { if (pageNumber == null) { pageNumber = 1; } string uri = WebAPI + "MaxviewEntries?"; uri += "signalId=" + id; uri += "&pageSize=5"; uri += "&pageNumber=" + pageNumber; //HTTP GET var responseTask = client.GetAsync(uri); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { string data = await result.Content.ReadAsStringAsync(); //use JavaScriptSerializer from System.Web.Script.Serialization JavaScriptSerializer JSserializer = new JavaScriptSerializer(); //deserialize to your class maxViewLogViewModel = JSserializer.Deserialize <MaxViewLogViewModel>(data); } else //web api sent error response { return(Content("Server error. Please contact administrator.")); } } return(PartialView("_MaxViewLogResult", maxViewLogViewModel)); }