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); } }
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; } }
public async Task Refresh() { if (!IsBusy) { IsBusy = true; } Businesses.Clear(); var businesses = await BusinessStore.GetItemsAsync(); Businesses.AddRange(businesses); CurrentLocation = await Geolocation.GetLocationAsync(); IsBusy = false; }
// 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; }