async Task Search(string searchTerm) { var stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); try { if (string.IsNullOrEmpty(searchBar.Text)) { return; } searchResults = await viewModel.Search(searchTerm); source = new DiscoverBeerSearchResultsSource(searchResults); source.DidSelectBeer += BeerSelected; beerResultsTable.Source = source; beerResultsTable.ReloadData(); View.BringSubviewToFront(beerResultsTable); } catch (Exception ex) { logger.Report(ex, "DiscoverViewController", "Search"); } finally { stopWatch.Stop(); } }
public async Task CheckInBeer(Beer beer, int score) { try { Acr.UserDialogs.UserDialogs.Instance.ShowLoading("Saving checkin"); var location = await CrossGeolocator.Current.GetPositionAsync(); var checkIn = new CheckIn { Beer = beer, User = await userStore.GetCurrentUser(), Longitude = location.Longitude, Latitude = location.Latitude }; var rating = new Rating { User = await userStore.GetCurrentUser(), Score = score, CheckIn = checkIn }; checkIn.Rating = rating; await checkInStore.InsertAsync(checkIn); await ratingStore.InsertAsync(rating); Acr.UserDialogs.UserDialogs.Instance.HideLoading(); } catch (Exception ex) { log.Report(ex); } }
async partial void BtnCheckIn_TouchUpInside(UIButton sender) { try { await viewModel.CheckInBeer(beer, rating); Acr.UserDialogs.UserDialogs.Instance.ShowSuccess("Saved!"); await DismissViewControllerAsync(true); } catch (Exception ex) { logger.Report(ex); Acr.UserDialogs.UserDialogs.Instance.ShowError(ex.Message); } }
public async Task <List <Beer> > TrendingBeers(int takeCount, double longittude, double latitude) { if (azure != null) { try { var parameters = new Dictionary <string, string>(); parameters.Add("takeCount", takeCount.ToString()); return(await azure.Client.InvokeApiAsync <List <Beer> >("TrendingBeers", HttpMethod.Get, parameters)); } catch (Exception ex) { insights.Report(ex); return(new List <Beer>()); } } throw new NullReferenceException("Azure Client is null"); }
async partial void BtnConnectWithFacebook_TouchUpInside(UIButton sender) { try { btnConnectWithFacebook.PulseToSize(0.9f, 0.2, false); var user = await azure.Client.LoginAsync(this, MobileServiceAuthenticationProvider.Facebook); Utils.Helpers.Settings.UserId = user.UserId; logger.Identify(user.UserId); UserAuthenticiated(); } catch (Exception ex) { logger.Report(ex); Acr.UserDialogs.UserDialogs.Instance.ShowError(ex.Message); } }