public DataTable GetStationList() { try { TGTravelServiceClient o = new TGTravelServiceClient(); o.Open(); Station s = o.getStationList(UserId, Password); Array st = s.stationList; DataTable dataTable = new DataTable(); dataTable.Columns.Add("stationId"); dataTable.Columns.Add("stationName"); foreach (StationDTO i in st) { DataRow dr = dataTable.NewRow(); dr["stationId"] = i.stationId; dr["stationName"] = i.stationName; dataTable.Rows.Add(dr); } o.Close(); return dataTable; } catch (Exception ex) { throw ex; } }
/// <summary> /// Method for getting stationslist /// </summary> /// <returns></returns> public String getSources(String URL, String ConsumerKey, String ConsumerSecret) { client = new TGTravelServiceClient("TGSWS", URL); Station response = client.getStationList(ConsumerKey, ConsumerSecret); DataTable dtCities = new DataTable(); //Check if response status is success if (response.status.code == "200") { dtCities = JsonConvert.DeserializeObject<DataTable>(JsonConvert.SerializeObject(response.stationList)); dtCities.Columns["stationId"].ColumnName = "id"; dtCities.Columns["stationName"].ColumnName = "name"; return JsonConvert.SerializeObject(dtCities); } else return String.Empty; }