public async Task AnimalControlTotal(IDialogContext context, LuisResult result) { string msg; Farm.RootObject currentFarm = await ConnectionTamberoAsyncFarm("AnimalControlTotal"); msg = "The last total produccion of your farm is " + currentFarm.farm.animalControlTotal; await context.PostAsync(msg); context.Wait(MessageReceived); }
public static async Task <Farm.RootObject> ConnectionTamberoAsyncFarm(string method) { Farm.RootObject currentFarm = new Farm.RootObject(); try { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://beta.tambero.com"); string url = string.Format("/apiv2/bot?method=" + method + "&apilicense=&apilang=es_AR&userid=&apikey="); var response = await client.GetAsync(url); if (HttpStatusCode.OK.ToString() == response.StatusCode.ToString()) { var result_query = response.Content.ReadAsStringAsync().Result; currentFarm = JsonConvert.DeserializeObject <Farm.RootObject>(result_query); } return(currentFarm); } catch (Exception ex) { return(currentFarm); } }