Beispiel #1
0
        public ActionResult <GenericResultViewModel <FlightResultViewModel> > Get(
            [FromQuery] string origin      = "STN",
            [FromQuery] string destination = "BDS")
        {
            var result = Helpers.EvaluateWithElapsed(() =>
            {
                return(_birdSearch
                       .Search(origin, destination, DateTime.Today.AddDays(1))
                       .GroupBy(x => x.Price)
                       .OrderByDescending(x => x.Key)
                       .Select(x => new FlightViewModel()
                {
                    Fare = x.Key,
                    Dates = x.Select(flight => flight.TimeDepartureUtc).ToList()
                })
                       .ToList());
            });

            return(new GenericResultViewModel <FlightResultViewModel>
            {
                Elapsed = result.Item2,
                Result = new FlightResultViewModel
                {
                    Origin = origin,
                    Destination = destination,
                    Flights = result.Item1
                }
            });
        }
Beispiel #2
0
        public void GetFlightsTest()
        {
            const string origin      = "STN";
            const string destination = "NYO";
            const int    datesCount  = 10;
            var          startDate   = DateTime.Today.AddDays(1);

            var flightDates = birdSearch.Search(origin, destination, startDate)
                              .Take(datesCount)
                              .ToList();

            Assert.Equal(datesCount, flightDates.Count);
        }
Beispiel #3
0
 private IEnumerable <FlightModel> GetUncachedItems(string origin, string destination, DateTime startDate)
 {
     return(_birdSearch.Search(origin, destination, startDate));
 }