public static async System.Threading.Tasks.Task <System.Collections.Generic.List <Models.HistoryU> > FetchHistory(Models.Company u) { // Create an HTTP web request using the URL: System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(new Uri(url1 + "History?email=" + u.Email)); request.ContentType = "application/json"; request.Method = "GET"; // Send the request to the server and wait for the response: using (System.Net.WebResponse response = await request.GetResponseAsync()) { // Get a stream representation of the HTTP web response: using (Stream stream = response.GetResponseStream()) { // Use this stream to build a JSON document object: System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream)); Console.Out.WriteLine("Response: {0}", jsonDoc.ToString()); // Return the JSON document: System.Collections.Generic.List <Models.HistoryU> lista = new System.Collections.Generic.List <Models.HistoryU>(); for (int i = 0; i != jsonDoc.Count; i++) { Models.HistoryU h = new Models.HistoryU { ID = Int32.Parse(jsonDoc[i]["ID"].ToString()), Description = jsonDoc[i]["Description"], Wyszukiwanie = jsonDoc[i]["Wyszukiwanie"], User = Int32.Parse(jsonDoc[i]["User"].ToString()), Expo = Int32.Parse(jsonDoc[i]["Expo"].ToString()) }; lista.Add(h); } return(lista); } } }
public static async System.Threading.Tasks.Task <Boolean> FetchCompanyHistoryAsync(Models.HistoryU obj) { Uri u = new Uri(url1 + "insertHistoryC?Search=" + obj.Wyszukiwanie + "&Description=" + obj.Description + "&Companyid=" + obj.User + "&Expoid=" + obj.Expo); System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(u); request.ContentType = "application/json"; request.Method = "GET"; // Send the request to the server and wait for the response: using (System.Net.WebResponse response = await request.GetResponseAsync()) { // Get a stream representation of the HTTP web response: using (Stream stream = response.GetResponseStream()) { // Use this stream to build a JSON document object: System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream)); Console.Out.WriteLine("Response: {0}", jsonDoc.ToString()); if (Boolean.Parse(jsonDoc["saved"].ToString()) == true) { return(true); } else { return(false); } } } return(false); }