public async Task <TantargyListaResponse> GetTantargyLista() { InitHttpClient(); var resp = new TantargyListaResponse(); try { var endpoint = string.Format(baseUrlApi + "/Tantargy/TantargyLista"); var r = await HttpClient.GetAsync(endpoint); if (r.IsSuccessStatusCode) { var contents = await r.Content.ReadAsStringAsync(); var returnValue = JsonConvert.DeserializeObject(contents); resp = JsonConvert.DeserializeObject <TantargyListaResponse>(returnValue.ToString()); } else { resp.ErrorCode = ERROR_NET; resp.ErrorMessage = r.StatusCode.ToString(); } return(resp); } catch (Exception ex) { resp.ErrorCode = ERROR_GENERIC; resp.ErrorMessage = ex.ToString(); return(resp); } }
public ActionResult Index() { if (Belepette.userLogged == null) { return(Redirect("/")); } else { if (Belepette.userLogged.ErrorCode != 0) { return(Redirect("/")); } } Proxy p = new Proxy(); TantargyListaResponse resp = new TantargyListaResponse(); resp = (TantargyListaResponse)Task.Run(() => p.GetTantargyLista()).Result; ViewData["TantargyLista"] = resp.TantargyLista; return(View()); }
public String TantargyLista() { TantargyListaResponse resp = new TantargyListaResponse(); try { resp.TantargyLista = dbmngr.TantargyListaKikero(); resp.ErrorCode = 0; } catch (Exception e) { resp.ErrorCode = -1; resp.ErrorMessage = e.Message; } return(JsonConvert.SerializeObject(resp)); }