public List <List <AmadeusVuelo> > GetVuelosIdaVuelta(string origin, string destination, string departuredate, string returnDate, string adults) { if (this.locationList == null) { LocationData locadata = new LocationData(); this.locationList = locadata.locations; } airlines = new Dictionary <string, string>(); this.token = GetToken(); var client = new RestClient(this.vueloEndPoint); var getRequest = new RestRequest(Method.GET); getRequest.RequestFormat = DataFormat.Json; getRequest.AddParameter("originLocationCode", origin, ParameterType.QueryString); getRequest.AddParameter("destinationLocationCode", destination, ParameterType.QueryString); getRequest.AddParameter("departureDate", departuredate, ParameterType.QueryString); getRequest.AddParameter("returnDate", returnDate, ParameterType.QueryString); getRequest.AddParameter("adults", adults, ParameterType.QueryString); getRequest.AddHeader("Authorization", $"Bearer {this.token}"); var response = client.Execute(getRequest); dynamic dy_vuelos = JsonConvert.DeserializeObject <dynamic>(response.Content); List <List <AmadeusVuelo> > vuelos = new List <List <AmadeusVuelo> >(); List <AmadeusVuelo> ida_vuelta = new List <AmadeusVuelo>(); dynamic iti = null; dynamic ida = null; dynamic vuelta = null; if (dy_vuelos.errors != null) { return(vuelos); } foreach (dynamic dyn_vuelo in dy_vuelos.data) { iti = dyn_vuelo.itineraries; ida = iti[0]; vuelta = iti[1]; if (ida.segments.Count == 1 && vuelta.segments.Count == 1) { ida.departureName = GetLocationCity(ida.segments[0].departure.iataCode.ToString()); vuelta.departureName = GetLocationCity(vuelta.segments[0].departure.iataCode.ToString()); ida.arrivalName = GetLocationCity(ida.segments[0].arrival.iataCode.ToString()); vuelta.arrivalName = GetLocationCity(vuelta.segments[0].arrival.iataCode.ToString()); AmadeusVuelo vuelo_ida = new AmadeusVuelo(dyn_vuelo.price, dyn_vuelo.numberOfBookableSeats, ida, adults); AmadeusVuelo vuelo_vuelta = new AmadeusVuelo(dyn_vuelo.price, dyn_vuelo.numberOfBookableSeats, vuelta, adults); ida_vuelta.Add(vuelo_ida); ida_vuelta.Add(vuelo_vuelta); vuelos.Add(ida_vuelta); ida_vuelta = new List <AmadeusVuelo>(); } } return(vuelos); }
public Vuelo amadeusVueloToVuelo(AmadeusVuelo amv) { return(new Vuelo { Origen = amv.DepartureCode, Destino = amv.ArrivalCode, FechaSalida = amv.DepartureTime, FechaLlegada = amv.ArrivalTime, Personas = amv.Persons, Precio = amv.Price, Aerolinea = amv.AirlineCode }); }