Ejemplo n.º 1
0
        private async void GetBusinessesWithReviews()
        {
            Businesses.Clear();
            var client = new Yelp.Api.Client("<INPUT YOUR YELP API KEY>");

            Yelp.Api.Models.SearchRequest searchRequest = new Yelp.Api.Models.SearchRequest();
            searchRequest.Location = Location;
            searchRequest.Term     = SearchString;
            var results = await client.SearchBusinessesAllAsync(searchRequest);

            Yelp.Api.Models.SearchResponse searchResponse = results;
            var businesses = searchResponse.Businesses;

            foreach (var b in businesses)
            {
                var business = new Business();
                business.Name    = b.Name.Trim();
                business.Address = b.Location.Address1.Trim();
                business.City    = b.Location.City.Trim();
                business.ZipCode = b.Location.ZipCode.Trim();
                business.State   = b.Location.State.Trim();
                business.Phone   = b.Phone.Trim();
                var reviewresult = await client.GetReviewsAsync(b.Id);

                var revs = reviewresult.Reviews;
                business.Reviews = revs.Select(x => Regex.Replace(x.Text.Trim(), @"\r\n?|\n", "")).ToArray();
                Businesses.Add(business);
            }
        }
Ejemplo n.º 2
0
        public async Task LoadBusinesses()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Businesses.Clear();
                var _bus = await Task.Run(() => GetBusinessesAsync());

                foreach (var business in _bus)
                {
                    Businesses.Add(business);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 3
0
        public async Task Refresh()
        {
            if (!IsBusy)
            {
                IsBusy = true;
            }

            Businesses.Clear();
            var businesses = await BusinessStore.GetItemsAsync();

            Businesses.AddRange(businesses);

            CurrentLocation = await Geolocation.GetLocationAsync();

            IsBusy = false;
        }
Ejemplo n.º 4
0
        // Prepare for the new world
        static public void onNewWorld(string key)
        {
            Plugin p = StockMarketPlugIn.theInstance.parent;

            Businesses.Clear();
            Companies.Clear();
            _theInstance._events.onNewWorld();
            IEnumerator ie = files.GetEnumerator();

            while (ie.MoveNext())
            {
                string filename = (string)ie.Current;
                using (Stream file = p.loadStream(filename))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(file);
                    IEnumerator ie2 = doc.ChildNodes.GetEnumerator();
                    while (ie2.MoveNext())
                    {
                        XmlNode cn = (XmlNode)ie2.Current;
                        if (cn.Name.Equals("companies"))
                        {
                            loadData(cn);
                        }
                        else if (cn.Name.Equals("events"))
                        {
                            _theInstance._events.loadData(cn);
                        }
                    }
                }
            }
            initTable();
            theInstance.setClockHandlers();
            World.world.otherObjects[key]          = theInstance;
            World.world.otherObjects[key + "rand"] = _random;
        }