Пример #1
0
        }//end Load_Recipe_Generator()

        //add comments here
        //--------------------Load_Recipe_Random(object sender, EventArgs e)---------------
        protected void Load_Recipe_Random(object sender, EventArgs e)
        {
            Info.Text = "";
            RecipeAPICall recipeCall = new RecipeAPICall();

            if (recipeCall == null)
            {
                RecipeInfo.Text = "Sorry. Could not load recipe at the moment, please try again later.";
                return;
            }


            string intstructions = recipeCall.getRandomRecipe();
            string name          = recipeCall.getRecipeName();
            string imgURL        = recipeCall.getImgURL();

            if (intstructions == null || name == null)
            {
                RecipeInfo.Text = "Sorry. Could not load recipe at the moment, please try again later.";
            }
            else
            {
                RecipeInfo.Text = intstructions;
                RecipeName.Text = name;

                if (imgURL != null)
                {
                    RecipeImage.Visible  = true;
                    RecipeImage.ImageUrl = imgURL;
                }
                else
                {
                    RecipeImage.Visible = false;
                }
                IMG_URL = imgURL;
            }
        }//end Load_Recipe_Random()
Пример #2
0
        }//end Page_Load()

        //This function uses the Receipe Generator class to come up with a a reccomendation based on weather information
        //for a given zipcode.
        //-------------------Load_Recipe_Generator(object sender, EventArgs e) -----------------------------------------------
        protected void Load_Recipe_Generator(object sender, EventArgs e)
        {
            Info.Text = "";
            if (Zipcode.Text.Length == 0)
            {
                RecipeInfo.Text = "Sorry, we need your zipcode to use the recommendation generator. Please enter a zipcode and try again";
                return;
            }

            RecipeGenerator recipeGenerator = new RecipeGenerator();
            RecipeAPICall   recipeCall      = new RecipeAPICall();

            if (recipeGenerator == null || recipeCall == null)
            {
                RecipeInfo.Text = "Sorry. Could not load recipe at the moment, please try again later.";
                return;
            }

            string foodType = recipeGenerator.generateRecipeType(Zipcode.Text);
            string type     = recipeCall.getRecipeBytype(foodType);
            string name     = recipeCall.getRecipeName();
            string imgURL   = recipeCall.getImgURL();

            if (type == null || name == null)
            {
                RecipeInfo.Text = "Sorry. Could not load recipe at the moment, please try again later.";
                return;
            }
            else
            {
                RecipeInfo.Text      = type;
                RecipeName.Text      = name;
                RecipeImage.Visible  = true;
                RecipeImage.ImageUrl = imgURL;
                IMG_URL = imgURL;
            }
        }//end Load_Recipe_Generator()