public static List <DictrictList> GetDictrict(string Province, string Amphur) { List <DictrictList> Dictrict = new List <DictrictList>(); #region //string sql = "Select DistrictId,DistrictName from tbl_District where ProvinceId = '" + Province.Trim() + "' AND AmphurId = '" + Amphur.Trim() + "'"; //DataSet ds_s = new Class1().SqlGet(sql, "tbl_District"); //long row = ds_s.Tables[0].Rows.Count; //if (row != 0) //{ // for (int i = 0; i < row; i++) // { // string DistrictName = ds_s.Tables["tbl_District"].Rows[i]["DistrictName"].ToString(); // string DistrictId = ds_s.Tables["tbl_District"].Rows[i]["DistrictId"].ToString(); // Dictrict.Add(new DictrictList { Dtext = DistrictName, Dvalue = DistrictId }); // } //} #endregion ApiGet apiData = new ApiGet(); var provincename = JsonConvert.DeserializeObject <List <DeliveryCost> >(apiData.GetDataDeliveryCost("http://ccp-info.com/APIDeliveryCost/api/DeliveryCost/getdata")); var q = provincename.Where(x => x.DeliveryCostProvince == Province && x.DeliveryCostDistrict == Amphur);//.GroupBy(x => new { x.DeliveryCostProvince, x.DeliveryCostDistrict,x.DeliveryCostTambon, x.DeliveryCostDistance, x.DeliveryCostY4, x.DeliveryCostY3 }); foreach (var d in q) { Dictrict.Add(new DictrictList { Dtext = d.DeliveryCostTambon, Dvalue = d.DeliveryCostDistance + "|" + d.DeliveryCostY4 + "|" + d.DeliveryCostY3 + "|" + d.DeliveryCostID }); } return(Dictrict); }
//public static async System.Threading.Tasks.Task<List<ProvinceList>> GetProvinceAsync() //{ // List<ProvinceList> Provinceget = new List<ProvinceList>(); // var result = await NetworkServices.GetDistance(); // #region // //foreach (var name in result) // //{ // // var P_Province = name.DeliveryCostProvince; // //} // #endregion // result.ForEach(c => // { // var P_Province = c.DeliveryCostProvince; // Provinceget.Add(new ProvinceList { Pvalueqq = P_Province.ToString()}); // } // ); // return Provinceget; //} public static List <ProvinceList> GetProvince() { List <ProvinceList> Province = new List <ProvinceList>(); #region //string sql = "Select ProvinceId,ProvinceName from tbl_Province"; //DataSet ds_s = new Class1().SqlGet(sql, "tbl_Provice"); //long row = ds_s.Tables[0].Rows.Count; //if (row != 0) //{ // for (int i = 0; i < row; i++) // { // string ProvinceId = ds_s.Tables["tbl_Provice"].Rows[i]["ProvinceId"].ToString(); // string provincename = ds_s.Tables["tbl_Provice"].Rows[i]["ProvinceName"].ToString(); // Province.Add(new ProvinceList { Ptext = provincename, Pvalue = ProvinceId }); // } //} #endregion ApiGet apiData = new ApiGet(); var provincename = JsonConvert.DeserializeObject <List <DeliveryCost> >(apiData.GetDataDeliveryCost("http://ccp-info.com/APIDeliveryCost/api/DeliveryCost/getdata")); var q = provincename.GroupBy(x => x.DeliveryCostProvince).Select(x => x); foreach (var d in q) { Province.Add(new ProvinceList { Ptext = d.Key }); //, Pvalue = ProvinceId } return(Province); }
public static List <AmpureList> GetAmpure(string Province) { List <AmpureList> Ampure = new List <AmpureList>(); #region //string sql = "Select AmphurId,AmphurName from tbl_Amphur where ProvinceId = '" + Province.Trim() + "'"; //DataSet ds_s = new Class1().SqlGet(sql, "tbl_Amphur"); //long row = ds_s.Tables[0].Rows.Count; //if (row != 0) //{ // for (int i = 0; i < row; i++) // { // string amphurname = ds_s.Tables["tbl_Amphur"].Rows[i]["AmphurName"].ToString(); // string AmphurId = ds_s.Tables["tbl_Amphur"].Rows[i]["AmphurId"].ToString(); // Ampure.Add(new AmpureList { Atext = amphurname, Avalue = AmphurId }); // } //} #endregion ApiGet apiData = new ApiGet(); var provincename = JsonConvert.DeserializeObject <List <DeliveryCost> >(apiData.GetDataDeliveryCost("http://ccp-info.com/APIDeliveryCost/api/DeliveryCost/getdata")); var q = provincename.Where(x => x.DeliveryCostProvince == Province).GroupBy(x => new { x.DeliveryCostProvince, x.DeliveryCostDistrict, x.DeliveryCostDistance, x.DeliveryCostY4, x.DeliveryCostY3 }); foreach (var d in q) { Ampure.Add(new AmpureList { Atext = d.Key.DeliveryCostDistrict, Avalue = d.Key.DeliveryCostDistance + "|" + d.Key.DeliveryCostY4 + "|" + d.Key.DeliveryCostY3 }); } return(Ampure); }