Example #1
0
        private async Task ExecuteSearchBeersCommand()
        {
            if (IsBusy)
            {
                return;
            }

            using (Insights.TrackTime("BeerSearch", "searchTerm", SearchTerm))
            {
                _userDialogs.ShowLoading("Searching...");

                IsBusy     = true;
                IsSearched = true;

                try
                {
                    var results = await _beerDrinkinClient.SearchBeersAsync(SearchTerm);

                    Beers.Clear();

                    if (results?.Count > 0)
                    {
                        foreach (var beer in results)
                        {
                            Beers.Add(beer);
                        }
                    }

                    _userDialogs.HideLoading();
                }
                catch (Exception ex)
                {
                    _userDialogs.ShowError(ex.Message);
                }
                finally
                {
                    IsBusy = false;
                }
            }
        }