Beispiel #1
0
        public IActionResult Start()
        {
            List <YelpModel> bars      = GetBars();
            LongAndLat       a         = new LongAndLat();
            decimal          latitude  = a.Latitude;
            decimal          longitude = a.Longitude;

            HttpWebRequest request = WebRequest.CreateHttp($"https://api.yelp.com/v3/businesses/search?term=bars&location=grand rapids&radius=1000&longitude={longitude}&latitude={latitude}");

            request.Headers.Add("Authorization", "Bearer 5AZ1TMhzZzb52DbbAMkydLPjNRSURY3x-DtC2o7qDjNTa2n96PSxuLZMmQoBy3WtX5q4EWUh4KQWVG1GG_nq_x2YLEssXjh5WF5kYw8E_VPmyRVMRfDHLwOYM0bXXXYx");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader    rd       = new StreamReader(response.GetResponseStream());
            string          ApiText  = rd.ReadToEnd();
            JToken          tokens   = JToken.Parse(ApiText);

            List <JToken> ts = tokens["businesses"].ToList();

            List <YelpModel> longlat = new List <YelpModel>();

            foreach (JToken t in ts)
            {
                YelpModel b = new YelpModel(t);
                longlat.Add(b);
            }

            return(longlat);
        }
Beispiel #2
0
        public List <YelpModel> GetBars()
        {
            HttpWebRequest request = WebRequest.CreateHttp("https://api.yelp.com/v3/businesses/search?term=bars&location=grand rapids");

            request.Headers.Add("Authorization", "Bearer 5AZ1TMhzZzb52DbbAMkydLPjNRSURY3x-DtC2o7qDjNTa2n96PSxuLZMmQoBy3WtX5q4EWUh4KQWVG1GG_nq_x2YLEssXjh5WF5kYw8E_VPmyRVMRfDHLwOYM0bXXXYx");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader    rd       = new StreamReader(response.GetResponseStream());
            string          ApiText  = rd.ReadToEnd();
            JToken          tokens   = JToken.Parse(ApiText);

            List <JToken> ts = tokens["businesses"].ToList();

            List <YelpModel> yelp = new List <YelpModel>();

            foreach (JToken t in ts)
            {
                YelpModel a = new YelpModel(t);
                yelp.Add(a);
            }

            return(yelp);
        }
Beispiel #3
0
 public IActionResult Search(YelpModel a)
 {
     return(RedirectToAction("Home", "Result"));
 }