public OfferHotelModule(ITravelOffersRepository offersRepository, HttpClient imageDownloadClient)
            : base("/offer")
        {
            this.TravelOffersRepository = offersRepository;

            this.ImageDownloadClient = imageDownloadClient;

            this.Get["/hotel/{hotelid}"] = this.GetHotel;

            this.Get["/hotel/{hotelid}/image/width/{width}/height/{height}"] = this.GetHotelImage;
        }
        public DestinationsModule(ITravelOffersRepository offersRepository)
        {
            this.Get["/destinations"] = _ => offersRepository.GetAllDestinations().OrderBy(s => s);

            this.Get["/destinations/{airport}"] = parameters =>
                {
                    var airport = HttpUtility.UrlDecode(parameters.airport);
                    IEnumerable<string> destinations = offersRepository.GetDestinationsForAirport(airport);

                    return destinations.OrderBy(s => s);
                };
        }
        public OfferSearchModule(ITravelOffersRepository offersRepository)
            : base("/offers")
        {
            this.Get["/from/{airport}"] = parameters =>
            {
                var airport = HttpUtility.UrlDecode(parameters.airport);
                IEnumerable<Offer> offers = offersRepository.GetOffers(airport);

                return offers.OrderBy(offer => offer.Date);
            };

            this.Get["/from/{airport}/on/{departuredate}"] = parameters =>
            {
                var airport = HttpUtility.UrlDecode(parameters.airport);
                DateTime departureDate;

                if (!DateTime.TryParse(HttpUtility.UrlDecode(parameters.departuredate), out departureDate))
                {
                    return ErrorResponse(HttpStatusCode.BadRequest, "Departure date format is invalid");
                }

                IEnumerable<Offer> offers = offersRepository.GetOffers(airport, departureDate);

                return offers.OrderBy(offer => offer.Date);
            };

            this.Get["/from/{airport}/to/{destination}"] = parameters =>
                {
                    var airport = HttpUtility.UrlDecode(parameters.airport);
                    var destination = HttpUtility.UrlDecode(parameters.destination);

                    IEnumerable<Offer> offers = offersRepository.GetOffers(airport, destination);
                    return offers.OrderBy(offer => offer.Date);
                };

            this.Get["/from/{airport}/to/{destination}/on/{departuredate}"] = parameters =>
                {
                    var airport = HttpUtility.UrlDecode(parameters.airport);
                    var destination = HttpUtility.UrlDecode(parameters.destination);
                    DateTime departure;

                    if (!DateTime.TryParse(HttpUtility.UrlDecode(parameters.departuredate), out departure))
                    {
                        return ErrorResponse(HttpStatusCode.BadRequest, "Departure date format is invalid");
                    }

                    IEnumerable<Offer> offers = offersRepository.GetOffers(airport, destination, departure);
                    return offers.OrderBy(offer => offer.Date);
                };
        }
 public OfferHotelModule(ITravelOffersRepository offersRepository)
     : this(offersRepository, new HttpClient())
 {
 }