Exemplo n.º 1
0
        /// <summary>
        /// Search Flights
        /// </summary>
        /// <param name="flightModel"></param>
        /// <returns>null</returns>
        public ActionResult Flights(FlightModel flightModel)
        {
            String fromDate = String.Format("{0:yyyy-MM-dd}", flightModel.FromDate);
            String toDate = String.Format("{0:yyyy-MM-dd}", flightModel.ToDate);

            var result = RequestService(flightModel, fromDate, toDate);
            var searchFlightViewModel = new SearchFlightViewModel();

            searchFlightViewModel = InsertFlightViewModel(result, searchFlightViewModel);

            return null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// request web service
        /// </summary>
        /// <param name="flightModel"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <returns>dynamic result</returns>
        private dynamic RequestService(FlightModel flightModel, String fromDate, String toDate)
        {
            string page = @"http://partners.api.skyscanner.net/apiservices/browsequotes/v1.0/" + Contants.Country + "/" + Contants.Currency +
                                            "/" + Contants.Locale + "/" + flightModel.FromCity + "/" + flightModel.ToCity + "/" + fromDate +
                                            "/" + toDate + "?apiKey=" + Contants.APIWebservice;

            WebClient webClient = new WebClient();
            String outputData = webClient.DownloadString(page);
            dynamic result = JsonConvert.DeserializeObject(outputData);

            return result;
        }