Esempio n. 1
0
        public List <AmadeusHotel> GetHotels(string cityCode, string adults)
        {
            if (this.locationList == null)
            {
                LocationData locadata = new LocationData();
                this.locationList = locadata.locations;
            }
            this.token = GetToken();
            var client     = new RestClient(this.hotelEndPoint);
            var getRequest = new RestRequest(Method.GET);

            getRequest.RequestFormat = DataFormat.Json;
            getRequest.AddParameter("cityCode", cityCode, ParameterType.QueryString);
            getRequest.AddParameter("adults", adults, ParameterType.QueryString);
            getRequest.AddHeader("Authorization", $"Bearer {this.token}");
            var                 response  = client.Execute(getRequest);
            dynamic             dy_hotels = JsonConvert.DeserializeObject <dynamic>(response.Content);
            List <AmadeusHotel> hotels    = new List <AmadeusHotel>();

            if (dy_hotels.errors != null)
            {
                return(hotels);
            }
            foreach (dynamic dyn_hotel in dy_hotels.data)
            {
                AmadeusHotel hot = new AmadeusHotel(dyn_hotel);
                hotels.Add(hot);
            }
            return(hotels);
        }
Esempio n. 2
0
 public Hotel amadeusHotelToHotel(AmadeusHotel amh)
 {
     return(new Hotel
     {
         HotelId = amh.HotelId,
         Name = amh.Name,
         CityCode = amh.CityCode,
         CityName = amh.CityName,
         Address = amh.Address,
         Description = amh.Description,
         Price = amh.Price
     });
 }