// Retrieves all the inner detail flight info for each of the trips and legs (connections) // for each flight related to the flight request submitted by the user protected static string GetDetails(Dictionary <string, Airport> airports, Google.Apis.QPXExpress.v1.Data.Data data, TripOption to, string inb, out int leg) { leg = 1; string res = "Outbound --> " + StrConsts._NewLine + StrConsts._NewLine; for (int i = 0; i <= to.Slice.Count - 1; i++) { res += GetSegmentLegs(ref leg, airports, data, to.Slice[i].Segment); if (inb.ToLower() == GatherQuestions.cStrGatherProcessOneWay.ToLower()) { break; } else if (i < to.Slice.Count - 1) { res += StrConsts._NewLine + StrConsts._NewLine + StrConsts._NewLine + StrConsts._NewLine + "Inbound (Return) --> " + StrConsts._NewLine + StrConsts._NewLine; } } return(res); }
// Retrieves all core data for a specific leg (flight connection) within the travel // itinerary, such as times, dates, cities, aircraft types, etc. protected static string GetSegmentLegs(ref int leg, Dictionary <string, Airport> airports, Google.Apis.QPXExpress.v1.Data.Data data, IList <SegmentInfo> segment) { string res = string.Empty; foreach (SegmentInfo sg in segment) { int i = leg; foreach (LegInfo li in sg.Leg) { res += "Leg " + i.ToString() + " -> " + StrConsts._NewLine + StrConsts._NewLine; string aircraft = GetAircraftName(data, li.Aircraft); string airline = GetAirlineName(data, sg.Flight.Carrier); string t1 = li.OriginTerminal ?? "Main"; string t2 = li.DestinationTerminal ?? "Main"; string kms = ToKms(li.Mileage ?? 0); string departure = PrettierDate(li.DepartureTime); string arrival = PrettierDate(li.ArrivalTime); string originCity = GetCityName(airports, data, li.Origin) + " (" + li.Origin + ")"; string destinationCity = GetCityName(airports, data, li.Destination) + " (" + li.Destination + ")"; string duration = GetDuration(li.Duration ?? 0); string line1 = $"From {originCity} to {destinationCity}" + StrConsts._NewLine + StrConsts._NewLine; string line2 = $"Flight {sg.Flight.Number}" + StrConsts._NewLine + StrConsts._NewLine; string line3 = $"Leaves: {departure}" + StrConsts._NewLine + StrConsts._NewLine; string line4 = $"Arrives: {arrival}" + StrConsts._NewLine + StrConsts._NewLine; string line5 = $"Duration: {duration}" + StrConsts._NewLine + StrConsts._NewLine; string line6 = $"From terminal {t1} to terminal {t2}" + StrConsts._NewLine + StrConsts._NewLine; string line7 = $"Meal: {li.Meal}" + StrConsts._NewLine + StrConsts._NewLine; string line8 = $"Mileage: {li.Mileage} = ({kms} Kms)" + StrConsts._NewLine + StrConsts._NewLine; string line9 = $"Aircraft: {aircraft}" + StrConsts._NewLine + StrConsts._NewLine; string line10 = $"Airline: {airline}" + StrConsts._NewLine + StrConsts._NewLine; string line11 = $"{li.OperatingDisclosure}" + StrConsts._NewLine + StrConsts._NewLine; res += line1 + line2 + line3 + line4 + line5 + line6 + line7 + line8 + line9 + line10 + line11; i++; } leg = i; } return(res); }
// Gets the airline name from the QPX Express flight results protected static string GetAirlineName(Google.Apis.QPXExpress.v1.Data.Data data, string code) { string res = string.Empty; foreach (CarrierData carrier in data.Carrier) { if (carrier.Code.ToLower() == code.ToLower()) { res = carrier.Name; break; } } return(res); }
// Gets the aircraft name from the QPX Express flight results protected static string GetAircraftName(Google.Apis.QPXExpress.v1.Data.Data data, string code) { string res = string.Empty; foreach (AircraftData craft in data.Aircraft) { if (craft.Code.ToLower() == code.ToLower()) { res = craft.Name; break; } } return(res); }
// Attemps to get the city from the list of cities contained within // the QPX Express flight results and if not found, gets it from the // worldwide airports list protected static string GetCityName(Dictionary <string, Airport> airports, Google.Apis.QPXExpress.v1.Data.Data data, string code) { string res = string.Empty; // Checks if the city exists within the QPX Express flight results foreach (CityData city in data.City) { if (city.Code.ToLower() == code.ToLower()) { res = city.Name; break; } } // If not found within the QPX Express flight results // the city is retrieved from the worldwide airports list return((res != string.Empty) ? res : GetCityNameFromAirports(airports, code)); }