public async Task <IEnumerable <Itinerary> > Search([FromBody] SearchCriteria criteria)
        {
            await Task.Delay(500); // Gotta look busy...

            var rng = new Random();

            return(Enumerable.Range(0, rng.Next(1, 5)).Select(_ => new Itinerary
            {
                Price = rng.Next(100, 2000),
                Outbound = new FlightSegment
                {
                    Airline = RandomAirline(),
                    FromAirportCode = criteria.FromAirport,
                    ToAirportCode = criteria.ToAirport,
                    DepartureTime = criteria.OutboundDate.AddHours(rng.Next(24)).AddMinutes(5 * rng.Next(12)),
                    ReturnTime = criteria.OutboundDate.AddHours(rng.Next(24)).AddMinutes(5 * rng.Next(12)),
                    DurationHours = 2 + rng.Next(10),
                    TicketClass = TicketClassData.Get(criteria.TicketClass)
                },
                Return = new FlightSegment
                {
                    Airline = RandomAirline(),
                    FromAirportCode = criteria.ToAirport,
                    ToAirportCode = criteria.FromAirport,
                    DepartureTime = criteria.ReturnDate.AddHours(rng.Next(24)).AddMinutes(5 * rng.Next(12)),
                    ReturnTime = criteria.ReturnDate.AddHours(rng.Next(24)).AddMinutes(5 * rng.Next(12)),
                    DurationHours = 2 + rng.Next(10),
                    TicketClass = TicketClassData.Get(criteria.TicketClass)
                },
            }));
        }
Exemplo n.º 2
0
        public Task <Itinerary[]> SearchAsync(SearchCriteria criteria)
        {
            var results = Enumerable.Range(0, random.Next(1, 5))
                          .Select(_ => new Itinerary
            {
                Price    = random.Next(100, 2000),
                Outbound = new FlightSegment
                {
                    Airline         = RandomAirline(),
                    FromAirportCode = criteria.FromAirport,
                    ToAirportCode   = criteria.ToAirport,
                    DepartureTime   = criteria.OutboundDate.AddHours(random.Next(24)).AddMinutes(5 * random.Next(12)),
                    ReturnTime      = criteria.OutboundDate.AddHours(random.Next(24)).AddMinutes(5 * random.Next(12)),
                    DurationHours   = 2 + random.Next(10),
                    TicketClass     = TicketClassData.Get(criteria.TicketClass)
                },
                Return = new FlightSegment
                {
                    Airline         = RandomAirline(),
                    FromAirportCode = criteria.ToAirport,
                    ToAirportCode   = criteria.FromAirport,
                    DepartureTime   = criteria.ReturnDate.AddHours(random.Next(24)).AddMinutes(5 * random.Next(12)),
                    ReturnTime      = criteria.ReturnDate.AddHours(random.Next(24)).AddMinutes(5 * random.Next(12)),
                    DurationHours   = 2 + random.Next(10),
                    TicketClass     = TicketClassData.Get(criteria.TicketClass)
                },
            })
                          .ToArray();

            return(Task.FromResult(results));
        }
Exemplo n.º 3
0
        private void SearchFlightForBestConference(IBrowserWrapper wrapper, FlightSearchPageObject page)
        {
            page.SearchForm.From = "Prague";
            page.SearchForm.To   = "London Heathrow";

            page.SearchForm.Depart = new DateTime(2018, 11, 21);
            page.SearchForm.Return = new DateTime(2018, 11, 24);

            page.SearchForm.TicketClass = TicketClassData.Get(TicketClass.Business);

            page.SearchForm.Search();
        }