Exemplo n.º 1
0
        public static Dictionary<string, Airport> makeAirport(JArray jsonArray)
        {
            Dictionary<string, Airport> retVal = new Dictionary<string, Airport>();
            for (int i = 0; i < jsonArray.Count; i++)
            {

                string key = jsonArray[i]["airport"].ToString();
                retVal[key] = new Airport();
                retVal[key].IATA = key;
                retVal[key].cityIata = jsonArray[i]["city"].ToString();
                retVal[key].cityName = jsonArray[i]["city_name"].ToString();
                retVal[key].locationLat = Double.Parse(jsonArray[i]["location"]["latitude"].ToString());
                retVal[key].locationLong = Double.Parse(jsonArray[i]["location"]["longitude"].ToString());
                retVal[key].name = jsonArray[i]["airport_name"].ToString();
            }
            return retVal;
        }
Exemplo n.º 2
0
        private void getFlights(Airport fromAirport, Airport toAirPort, string startDate, string returnDate,
            int adultsNum, int childrenNum, int infantsNum, bool direct, int maxPrice, TRAVEL_CLASS travelClass)
        {
            string originApi = "origin=" + fromAirport.IATA;
            string dstApi = "&destination=" + toAirPort.IATA;
            string departureDateApi = "&departure_date=" + startDate;
            string retDateApi = "&return_date=" + returnDate;
            string adultsApi = this.adultsNum > 0? "&adults=" + adultsNum.ToString() : "" ;
            string childrenApi = this.childrenNum > 0 ? "&children=" + childrenNum.ToString() : "";
            string infantsApi = this.infantsNum > 0 ? "&infants=" + infantsNum.ToString() : "";
            string directApi = "&direct=false"; //+ direct.ToString().ToLower();
            string currencyApi = "&currency=USD";
            string maxPriceApi = "&max_price=" + maxPrice.ToString();
            string travelClassApi = "&travel_class=" + travelClass.ToString();
            string resultsNumApi = "&number_of_results=1";
            string appApiKey = "&apikey=" + Config.amadeuisAppId;

            string apiUrl = Config.getFlightsApi + originApi + dstApi + departureDateApi + retDateApi + adultsApi + childrenApi
                + infantsApi + directApi + currencyApi + maxPriceApi + travelClassApi + resultsNumApi + appApiKey;

            SendBadHttpRequest.sendHttpRequest(apiUrl, getFlightsComplete);



        }