private void addProdMarket(object sender, EventArgs e) { var data = cropPicker.Items[cropPicker.SelectedIndex]; var id = CropItems.FirstOrDefault(x => x.Value == data).Key; var quant = quantity.Text; System.Diagnostics.Debug.WriteLine("Market Input======={0}====={1}====={2}=====", id, data, quant); Navigation.PushAsync(new showMarketsFarmer(id)); //DependencyService.Get<call_web_service>().addApproxProd(Global_portable.email, id, quant); Approx_Prod data2 = new Approx_Prod(); data2.email = Global_portable.email; data2.apx_prod = quant; data2.cropid = id; string json = JsonConvert.SerializeObject(data2); System.Diagnostics.Debug.WriteLine("Json object" + json); string url = "http://192.168.0.4:5010/add_appx_production"; var content = new StringContent(json, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var result = client.PostAsync(url, content).Result; string res = ""; using (HttpContent content3 = result.Content) { // ... Read the string. Task <string> result2 = content3.ReadAsStringAsync(); res = result2.Result; System.Diagnostics.Debug.WriteLine("response in farm data page ress" + res); } } }
public showMarketsFarmer(string id) { InitializeComponent(); String[] cropList = new String[100]; String[] marketname = new String[100]; int j = 0; cropID = id; //cropList = DependencyService.Get<call_web_service>().getMarketsFarmer(cropID); Approx_Prod data2 = new Approx_Prod(); data2.cropid = cropID; string json = JsonConvert.SerializeObject(data2); System.Diagnostics.Debug.WriteLine("Json object" + json); string url = "http://192.168.0.4:5010/get_markets"; var content = new StringContent(json, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var result = client.PostAsync(url, content).Result; string res = ""; using (HttpContent content3 = result.Content) { // ... Read the string. Task <string> result2 = content3.ReadAsStringAsync(); res = result2.Result; System.Diagnostics.Debug.WriteLine("response in farm data page ress" + res); Market final = JsonConvert.DeserializeObject <Market>(res); foreach (var x in final.marketid) { System.Diagnostics.Debug.WriteLine(x); cropList[j] = x; j = j + 1; } j = 0; foreach (var x in final.marketname) { System.Diagnostics.Debug.WriteLine(x); marketname[j] = x; j = j + 1; } } } System.Diagnostics.Debug.WriteLine("MarketList length======{0}", cropList.Length); for (int i = 0; i < j; i++) { string marketID = ""; string marketName = ""; marketID = cropList[i]; marketName = marketname[i]; System.Diagnostics.Debug.WriteLine("MarketList======{0}", cropList[i]); CropItems.Add(marketID, string.Format("Market : {0}", marketName)); } //for (int i = 0; i < j; i++) //{ // string marketID = ""; // string marketName = ""; // int currloc = 0; // int nextloc = 0; // nextloc = cropList[i].IndexOf(",", currloc); // marketID = cropList[i].Substring(0, nextloc); // currloc = nextloc + 1; // marketName = cropList[i].Substring(currloc); // System.Diagnostics.Debug.WriteLine("MarketList======{0}", cropList[i]); // CropItems.Add(marketID, string.Format("Market : {0}", marketName)); //} lstView.ItemsSource = CropItems.ToList(); }