コード例 #1
0
        async void OnFindButtonClicked(object sender, EventArgs e)
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                return;
            }

            // Turn on network indicator
            this.IsBusy             = true;
            noRecipeLabel.IsVisible = false;

            try
            {
                recipes.Clear();
                string query            = newRecipe.Text;
                var    recipeCollection = await manager.GetAllByIngredients(query);

                foreach (Recipe recipe in recipeCollection)
                {
                    if (recipe.thumbnail == "")
                    {
                        recipe.thumbnail = "RecipeBook.png";
                    }
                    if (recipes.All(b => b.title != recipe.title))
                    {
                        recipes.Add(recipe);
                    }
                }
                if (recipeCollection != null && (recipeCollection.Count() > 0))
                {
                    noRecipeLabel.IsVisible = false;
                }
                else
                {
                    noRecipeLabel.IsVisible = true;
                }
            }
            finally
            {
                this.IsBusy = false;
            }
        }