예제 #1
0
        public async Task <IQueryable <GooglePlaceModel.Result> > GetTopDestinations()
        {
            var singleTracksApi = _singleTracksApi;

            var request = (HttpWebRequest)WebRequest.Create(singleTracksApi.AllUsaPlaces.ToString());

            request.Accept = "application/json";
            request.Headers["X-Mashape-Key"] = singleTracksApi.X_Mashape_Key.ToString();

            WebResponse response = await request.GetResponseAsync();

            var raw = String.Empty;

            using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8, true, 1024, true))
            {
                raw = reader.ReadToEnd();
            }
            var allresults = JsonConvert.DeserializeObject <DestinationModel.RootObject>(raw);

            var googlePlaces = new List <GooglePlaceModel.Result>();

            googlePlaces = await TypeConversions.ToGooglePlaceFormat(allresults.places);

            return(googlePlaces.AsQueryable());
        }