Example #1
0
        /// <summary>
        /// Queries the API by the input values from the user, and prints
        /// the result on the console.
        /// </summary>
        /// <param name="term">The search term to query.</param>
        /// <param name="location">The location of the business to query.</param>
        public static int QueryAPIAndPrintResult(string term, string location, string offset)
        {
            int found  = 0;
            var client = new YelpAPIClient();

            Console.WriteLine("Querying for {0} in {1}...", term, location);

            JObject response = client.Search(term, location, offset);

            JArray businesses = (JArray)response.GetValue("businesses");

            found = businesses.Count;
            if (businesses.Count == 0)
            {
                Console.WriteLine("No businesses for {0} in {1} found.", term, location);
                return(found);
            }

            foreach (var business in businesses)
            {
                string id = (string)business["id"];
                response = client.GetBusiness(id);
                Console.WriteLine(String.Format("Result for business {0} found:", id));
                Console.WriteLine(response.ToString());
                Console.WriteLine("-------------------------------------------");
            }

            return(found);
        }
Example #2
0
        /// <summary>
        /// Queries the API by the input values from the user, and prints
        /// the result on the console.
        /// </summary>
        /// <param name="term">The search term to query.</param>
        /// <param name="location">The location of the business to query.</param>
        public static void QueryAPIAndPrintResult(string term, string location)
        {
            var client = new YelpAPIClient();

            Console.WriteLine("Querying for {0} in {1}...", term, location);

            JObject response = client.Search(term, location);

            JArray businesses = (JArray)response.GetValue("businesses");

            if (businesses.Count == 0)
            {
                Console.WriteLine("No businesses for {0} in {1} found.", term, location);
                return;
            }

            string business_id = (string)businesses[0]["id"];

            Console.WriteLine(
                "{0} businesses found, querying business info for the top result \"{1}\"...",
                businesses.Count,
                business_id
                );

            response = client.GetBusiness(business_id);

            Console.WriteLine(String.Format("Result for business {0} found:", business_id));
            Console.WriteLine(response.ToString());
        }
Example #3
0
        /// <summary>
        /// Queries the API by the input values from the user, and prints
        /// the result on the console.
        /// </summary>
        /// <param name="term">The search term to query.</param>
        /// <param name="location">The location of the business to query.</param>
        public static void QueryAPIAndPrintResult(string term, string location)
        {
            var client = new YelpAPIClient();

            Console.WriteLine("Querying for {0} in {1}...", term, location);

            JObject response = client.Search(term, location);

            JArray businesses = (JArray)response.GetValue("businesses");

            if (businesses.Count == 0)
            {
                Console.WriteLine("No businesses for {0} in {1} found.", term, location);
                return;
            }

            string business_id = (string)businesses[0]["id"];

            Console.WriteLine(
                "{0} businesses found, querying business info for the top result \"{1}\"...",
                businesses.Count,
                business_id
            );

            response = client.GetBusiness(business_id);

            Console.WriteLine(String.Format("Result for business {0} found:", business_id));
            Console.WriteLine(response.ToString());
        }