public void FillData(string origin, string destination, string startDate, string endDate, string originCountry, string originCity, string destCountry, string destCity) { this.departureDate = AdjustDateToAPI(startDate); this.returnDate = AdjustDateToAPI(endDate); this.originCity = originCity; this.originCountry = originCountry; this.destinationCity = destCity; this.destinationCountry = destCountry; this.originCodeCity = FixCode(origin); this.destinationCodeCity = FixCode(destination); BuildURL(); GetJson(); if (response != "") // there was an error with the request { return; } dynamic results = JsonConvert.DeserializeObject(json); for (int i = 0; i < results.results.Count; ++i) { FlightRouteVM temp_outbound = new FlightRouteVM(); FlightRouteVM temp_inbound = new FlightRouteVM(); temp_outbound.DepartureDate = FixDate(results.results[i].itineraries[0].outbound.flights[0].departs_at.ToString().Substring(0, 10)); temp_outbound.DepartureTime = results.results[i].itineraries[0].outbound.flights[0].departs_at.ToString().Substring(11, 5); temp_outbound.ArrivalDate = FixDate(results.results[i].itineraries[0].outbound.flights[0].arrives_at.ToString().Substring(0, 10)); temp_outbound.ArrivalTime = results.results[i].itineraries[0].outbound.flights[0].arrives_at.ToString().Substring(11, 5); temp_outbound.DepartureAirportCode = results.results[i].itineraries[0].outbound.flights[0].origin.airport; temp_outbound.ArrivalAirportCode = results.results[i].itineraries[0].outbound.flights[0].destination.airport; temp_outbound.FlightNumber = results.results[i].itineraries[0].outbound.flights[0].flight_number; temp_outbound.DepartureAirportName = GetAirportName(results.results[i].itineraries[0].outbound.flights[0].origin.airport.ToString()); temp_outbound.ArrivalAirportName = GetAirportName(results.results[i].itineraries[0].outbound.flights[0].destination.airport.ToString()); temp_outbound.DepartureDay = ToolsClass.DayOfTheWeek(FixDate(results.results[i].itineraries[0].outbound.flights[0].departs_at.ToString().Substring(0, 10))); temp_outbound.ArrivalDay = ToolsClass.DayOfTheWeek(FixDate(results.results[i].itineraries[0].outbound.flights[0].arrives_at.ToString().Substring(0, 10))); temp_outbound.TimeDuration = ToolsClass.TimeDifferences(results.results[i].itineraries[0].outbound.flights[0].departs_at.ToString().Substring(11, 5), results.results[i].itineraries[0].outbound.flights[0].arrives_at.ToString().Substring(11, 5)); temp_inbound.DepartureDate = FixDate(results.results[i].itineraries[0].inbound.flights[0].departs_at.ToString().Substring(0, 10)); temp_inbound.DepartureTime = results.results[i].itineraries[0].inbound.flights[0].departs_at.ToString().Substring(11, 5); temp_inbound.ArrivalDate = FixDate(results.results[i].itineraries[0].inbound.flights[0].arrives_at.ToString().Substring(0, 10)); temp_inbound.ArrivalTime = results.results[i].itineraries[0].inbound.flights[0].arrives_at.ToString().Substring(11, 5); temp_inbound.DepartureAirportCode = results.results[i].itineraries[0].inbound.flights[0].origin.airport; temp_inbound.ArrivalAirportCode = results.results[i].itineraries[0].inbound.flights[0].destination.airport; temp_inbound.FlightNumber = results.results[i].itineraries[0].inbound.flights[0].flight_number; temp_inbound.DepartureAirportName = GetAirportName(results.results[i].itineraries[0].inbound.flights[0].origin.airport.ToString()); temp_inbound.ArrivalAirportName = GetAirportName(results.results[i].itineraries[0].inbound.flights[0].destination.airport.ToString()); temp_inbound.DepartureDay = ToolsClass.DayOfTheWeek(FixDate(results.results[i].itineraries[0].inbound.flights[0].departs_at.ToString().Substring(0, 10))); temp_inbound.ArrivalDay = ToolsClass.DayOfTheWeek(FixDate(results.results[i].itineraries[0].inbound.flights[0].arrives_at.ToString().Substring(0, 10))); temp_inbound.TimeDuration = ToolsClass.TimeDifferences(results.results[i].itineraries[0].inbound.flights[0].departs_at.ToString().Substring(11, 5), results.results[i].itineraries[0].inbound.flights[0].arrives_at.ToString().Substring(11, 5)); outbound.Add(temp_outbound); inbound.Add(temp_inbound); seatsRemaining.Add(results.results[i].itineraries[0].inbound.flights[0].booking_info.seats_remaining.ToString()); airline.Add(results.results[i].itineraries[0].inbound.flights[0].marketing_airline.ToString()); price.Add(Convert.ToDouble(results.results[i].fare.total_price.ToString())); } }
// ----------------------------- this view is only for static run (TEMP VIEW) public ActionResult ViewFlightInfo() { List <string> airlineLST = new List <string>(); airlineLST.Add("LY"); List <double> priceLST = new List <double>(); priceLST.Add(2565.42); List <string> seatsRemainingLST = new List <string>(); seatsRemainingLST.Add("9"); List <FlightRouteVM> outboundLST = new List <FlightRouteVM>(); outboundLST.Add(new FlightRouteVM() { ArrivalAirportCode = "LHR", ArrivalDate = "15.06.2018", ArrivalTime = "13:35", DepartureAirportCode = "TLV", DepartureDate = "15.06.2018", DepartureTime = "10:10", FlightNumber = "315", ArrivalAirportName = "London Heathrow Airport", DepartureAirportName = "Ben Gurion Airport", DepartureDay = ToolsClass.DayOfTheWeek("15.06.2018"), ArrivalDay = ToolsClass.DayOfTheWeek("15.06.2018"), }); List <FlightRouteVM> inboundLST = new List <FlightRouteVM>(); inboundLST.Add(new FlightRouteVM() { ArrivalAirportCode = "TLV", ArrivalDate = "25.06.2018", ArrivalTime = "15:00", DepartureAirportCode = "LHR", DepartureDate = "25.06.2018", DepartureTime = "08:10", FlightNumber = "165", ArrivalAirportName = "Ben Gurion Airport", DepartureAirportName = "London Heathrow Airport", DepartureDay = ToolsClass.DayOfTheWeek("25.06.2018"), ArrivalDay = ToolsClass.DayOfTheWeek("25.06.2018"), }); FlightSearchResultsVM flightSearchResultsVM = new FlightSearchResultsVM() { selectedFlight = 0, departureDate = "15.06.2018", returnDate = "25.06.2018", originCountry = "UK", originCity = "London", destinationCountry = "Israel", destinationCity = "Tel Aviv", originCodeCity = "LON", destinationCodeCity = "TLV", outbound = outboundLST, inbound = inboundLST, airline = airlineLST, price = priceLST, seatsRemaining = seatsRemainingLST }; return(View(LoadDataFor_ViewFlightInfo(flightSearchResultsVM))); }