示例#1
0
        public void LocationWithCoordinates()
        {
            var o    = GetOptions();
            var yelp = new Yelp(o);

            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "food"
                },
                LocationOptions = new LocationOptions()
                {
                    location    = "bellevue",
                    coordinates = new CoordinateOptions()
                    {
                        latitude  = 37.788022,
                        longitude = -122.399797
                    }
                }
            };

            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
示例#2
0
        //
        // GET: /Business/

        public ActionResult Details(string id)
        {
            Yelp y      = new Yelp(MvcApplication.Options);
            var  result = y.GetBusiness(id);

            return(View(result));
        }
示例#3
0
        public void BusinessTest()
        {
            var y       = new Yelp(Config.Options);
            var results = y.GetBusiness("yelp-san-francisco").Result;

            Assert.IsTrue(results != null);
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult Results(SimpleSearchModel model)
        {
            Yelp yelp    = new Yelp(MvcApplication.Options);
            var  results = yelp.Search(model.Term, model.Location);

            return(View(results));
        }
示例#5
0
        public void LocationWithCoordinates()
        {
            var yelp = new Yelp(Config.Options);

            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "food"
                },
                LocationOptions = new LocationOptions()
                {
                    location    = "bellevue",
                    coordinates = new CoordinateOptions()
                    {
                        latitude  = 37.788022,
                        longitude = -122.399797
                    }
                }
            };

            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
示例#6
0
        //
        // GET: /Business/

        public ActionResult Details(string id)
        {
            Yelp y      = new Yelp(Config.Options);
            var  result = y.GetBusiness(id).Result;

            return(View(result));
        }
示例#7
0
        public static YelpReviewModel GetYelpBiz(BizInfo vBiz)
        {
            YelpReviewModel yrm  = new YelpReviewModel();
            Yelp            yelp = new Yelp(Config.Options);

            //  var results = yelp.Search("Restaurants " + vBiz.BizCuisines.FirstOrDefault().CuisineTypeName, vBiz.BizAddressString).Result;
            YelpSharp.Data.Business biz = new YelpSharp.Data.Business();
            // biz=results.businesses.FirstOrDefault(e => e.phone == vBiz.ContactInfo.Phone);
            // biz = (biz == null) ? null : yelp.GetBusiness(biz.id).Result;
            biz     = string.IsNullOrEmpty(vBiz.YelpBizId)? null: yelp.GetBusiness(vBiz.YelpBizId).Result;
            yrm.Biz = biz;
            if (biz != null)
            {
                if (biz.reviews != null && biz.reviews.Count > 0)
                {
                    int lRandIndex = Helper.GetRandItem(0, biz.reviews.Count - 1);
                    yrm.Review = biz.reviews[lRandIndex];
                    if (yrm.Review.user != null)
                    {
                        yrm.User = yrm.Review.user;
                    }
                }
            }
            return(yrm);
        }
示例#8
0
        public void ErrorTest_UNAVAILABLE_BUSINESS()
        {
            Yelp     y        = new Yelp(Config.Options);
            Business business = y.GetBusiness("foo-bar").Result;

            Assert.IsNull(business);
        }
示例#9
0
        public void LimitTest()
        {
            var y             = new Yelp(Config.Options);
            var searchOptions = new SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term  = "coffee",
                    limit = 15,
                },
                LocationOptions = new LocationOptions()
                {
                    location = "seattle, wa"
                }
            };
            var results = y.Search(searchOptions).Result;

            if (results.error != null)
            {
                Assert.Fail(results.error.text);
            }
            if (results.businesses.Count != 15)
            {
                Assert.Fail(string.Format("Limit test returned {0} results instead of 15", results.businesses.Count));
            }

            Console.WriteLine(results);
        }
示例#10
0
        public void BusinessTest()
        {
            var o       = GetOptions();
            var y       = new Yelp(o);
            var results = y.GetBusiness("yelp-san-francisco");

            Console.WriteLine(results);
        }
示例#11
0
        public async void GetBusiness(string businessId)
        {
            this.Business = null;

            Yelp yelp = new Yelp(Config.Options);

            this.Business = await yelp.GetBusiness(businessId);
        }
示例#12
0
        public void BasicTest()
        {
            var o       = GetOptions();
            var y       = new Yelp(o);
            var results = y.Search("coffee", "seattle, wa");

            Console.WriteLine(results);
        }
示例#13
0
 public Venue(Yelp.Business theBusiness)
 {
     id = theBusiness.id;
     title = theBusiness.name;
     image = theBusiness.image_url;
     rating = theBusiness.rating;
     ratingImage = theBusiness.rating_img_url_large;
 }
示例#14
0
 public Venue(Yelp.Business theBusiness)
 {
     id = theBusiness.id;
     title = theBusiness.name;
     image = theBusiness.image_url;
     rating = theBusiness.rating;
     ratingImage = theBusiness.rating_img_url_large;
     address = theBusiness.location.address[0];
 }
示例#15
0
        public void GetJsonAsyncTest2()
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("term", "delis");
            Yelp yelp = new Yelp();
            var  json = yelp.GetJsonAsync(dict);

            Assert.IsNotNull(json);
        }
示例#16
0
        public void SearchByPhoneTest()
        {
            var y       = new Yelp(Config.Options);
            var results = y.SearchByPhone("4159083801").Result;

            Assert.IsNotNull(results);
            Assert.IsNotNull(results.businesses);
            Assert.IsNotNull(results.businesses.FirstOrDefault());
            Assert.AreEqual <string>("yelp-san-francisco", results.businesses.First().id);
        }
示例#17
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var yelp = new Yelp(Config.Options);
            var task = yelp.Search(txtSearch.Text, txtLocation.Text);

            task.ContinueWith((results) =>
            {
                App.ViewModel = new ViewModels.SearchResultViewModel(results.Result);
                NavigationService.Navigate(new Uri("/SearchResultsPage.xaml"));
            });
        }
示例#18
0
        public void BasicTest()
        {
            var y       = new Yelp(Config.Options);
            var results = y.Search("coffee", "seattle, wa").Result;

            if (results.error != null)
            {
                Assert.Fail(results.error.text);
            }
            Console.WriteLine(results);
        }
示例#19
0
        public void ErrorTest_UNSPECIFIED_LOCATION()
        {
            var y = new Yelp(Config.Options);

            var searchOptions = new SearchOptions();

            var results = y.Search(searchOptions).Result;

            Assert.IsTrue(results.error != null);
            Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.UNSPECIFIED_LOCATION);
            Console.WriteLine(results);
        }
示例#20
0
        public void LocationByBounds()
        {
            var yelp          = new Yelp(Config.Options);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                LocationOptions = new CoordinateOptions()
                {
                    latitude  = 37.788022,
                    longitude = -122.399797
                }
            };
            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
示例#21
0
        public async Task <IActionResult> Details(string businessId)
        {
            var googleKey = _configuration.GetSection("API_KEY").GetSection("GoogleKey").Value;

            var httpClient = HttpClientFactory.Create();

            string detailSearch = $"https://maps.googleapis.com/maps/api/place/details/json?place_id={businessId}&fields=name,formatted_phone_number&key={googleKey}";


            HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(detailSearch);

            try
            {
                if (httpResponseMessage.IsSuccessStatusCode)
                {
                    var    content = httpResponseMessage.Content;
                    string data    = await content.ReadAsStringAsync();

                    BusinessDetail detail = ConvertToDetail(data);
                    ViewBag.detailData = detail;

                    var client = new HttpClient();
                    var apiKey = _configuration.GetSection("API_KEY").GetSection("YelpKey").Value;

                    var YelpSearch = $"https://api.yelp.com/v3/businesses/search/phone?phone=+1{detail.PhoneNumber}";
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + apiKey);

                    string response = await client.GetStringAsync(YelpSearch);

                    Yelp yelpUrl = ConvertToYelpUrl(response);

                    if (yelpUrl.Url == "Null")
                    {
                        ViewBag.url = "Null";
                    }
                    ViewBag.url = yelpUrl.Url;
                    return(View());
                }
                else
                {
                    return(View("Index"));
                }
            }
            catch (HttpRequestException)
            {
                return(View("Index"));
            }
        }
示例#22
0
        public async void Search()
        {
            this.Businesses.Clear();

            Yelp yelp = new Yelp(Config.Options);

            SearchResults searchResults = await yelp.Search(this.SearchOptions);

            if (searchResults != null && searchResults.businesses != null)
            {
                for (int count = 0; count < searchResults.businesses.Count; count++)
                {
                    this.Businesses.Add(searchResults.businesses[count]);
                }
            }
        }
示例#23
0
        public void VerifyLocationInResult()
        {
            var y       = new Yelp(Config.Options);
            var results = y.Search("coffee", "seattle, wa").Result;

            if (results.error != null)
            {
                Assert.Fail(results.error.text);
            }
            var bus = results.businesses[0];

            if (bus.location.coordinate == null)
            {
                Assert.Fail("No coordinate found on location for business");
            }
        }
示例#24
0
        public void LocationWithRadius()
        {
            var yelp          = new Yelp(Config.Options);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "food", radius_filter = 5
                },
                LocationOptions = new LocationOptions()
                {
                    location = "bellevue"
                }
            };
            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
示例#25
0
        private void GetYelpData(Guid id, string yelpId)
        {
            var options = new Options
            {
                AccessToken       = ConfigurationManager.AppSettings["YelpAPIToken"],
                AccessTokenSecret = ConfigurationManager.AppSettings["YelpAPITokenSecret"],
                ConsumerKey       = ConfigurationManager.AppSettings["YelpAPIConsumerKey"],
                ConsumerSecret    = ConfigurationManager.AppSettings["YelpAPIConsumerSecret"]
            };

            var      yelp     = new Yelp(options);
            Business business = yelp.GetBusiness(yelpId).Result;

            if (business != null)
            {
                UpdateAccount(id, business.rating);
            }
        }
示例#26
0
        public void MultipleCategories()
        {
            var yelp          = new Yelp(Config.Options);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    category_filter = "climbing,bowling"
                },
                LocationOptions = new LocationOptions()
                {
                    location = "Seattle"
                }
            };
            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
示例#27
0
        public void BusinessReviewTest()
        {
            var y       = new Yelp(Config.Options);
            var results = y.GetBusiness("yelp-san-francisco").Result;

            Assert.IsTrue(results != null);

            Assert.IsNotNull(results.reviews);
            Assert.AreNotEqual(0, results.review_count);

            Assert.AreNotEqual(0, results.reviews.Count);

            var firstReview = results.reviews[0];

            Assert.IsNotNull(firstReview.rating_image_url);
            Assert.IsNotNull(firstReview.rating_image_small_url);
            Assert.IsNotNull(firstReview.rating_image_large_url);
        }
示例#28
0
        public void ErrorTest_UNAVAILABLE_FOR_LOCATION()
        {
            var y = new Yelp(Config.Options);

            var searchOptions = new SearchOptions()
            {
                LocationOptions = new CoordinateOptions()
                {
                    latitude  = 1,
                    longitude = 1
                }
            };

            var results = y.Search(searchOptions).Result;

            Assert.IsTrue(results.error != null);
            Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.UNAVAILABLE_FOR_LOCATION);
            Console.WriteLine(results);
        }
示例#29
0
        public void VerifyCoordinatesWithRadius()
        {
            var yelp          = new Yelp(Config.Options);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    radius_filter = 3000
                },
                LocationOptions = new CoordinateOptions()
                {
                    latitude  = 47.603525,
                    longitude = -122.329580
                }
            };
            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
示例#30
0
        public void ErrorTest_INVALID_SIGNATURE()
        {
            var o = GetOptions();
            var y = new Yelp(o);

            var searchOptions = new SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "coffee + tea"
                }
            };

            var results = y.Search(searchOptions);

            Assert.IsTrue(results.error != null);
            Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.INVALID_SIGNATURE);
            Console.WriteLine(results);
        }
示例#31
0
        public void MultipleCategories()
        {
            var o             = GetOptions();
            var yelp          = new Yelp(o);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    category_filter = "climbing,bowling"
                },
                LocationOptions = new LocationOptions()
                {
                    location = "Seattle"
                }
            };
            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
示例#32
0
        public void LocationWithRadius()
        {
            var o             = GetOptions();
            var yelp          = new Yelp(o);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "food", radius_filter = 5
                },
                LocationOptions = new LocationOptions()
                {
                    location = "bellevue"
                }
            };
            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }