예제 #1
0
        //Creates a shedule with the given parameters. Calls the makeMealRequest from rClient
        private void buttonSearchSchedule_Click(object sender, EventArgs e)
        {
            RESTClient rClient = new RESTClient();

            rClient.endPoint = " https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/mealplans/generate?timeFrame=" + timeFrame + "&targetCalories=" + targetCalories;

            try{
                meal = rClient.makeMealRequest();
                dataGridViewSchedule.Rows.Clear();
                dataGridViewSchedule.Refresh();

                for (int i = 0; i < 21; i++)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataGridViewSchedule);
                    row.Cells[0].Value = meal[i].getId();
                    row.Cells[1].Value = meal[i].getDay();
                    row.Cells[2].Value = meal[i].getName();
                    dataGridViewSchedule.Rows.Add(row);
                }
                int             RowIndex = dataGridViewSchedule.RowCount - 1;
                DataGridViewRow R        = dataGridViewSchedule.Rows[RowIndex];
            }catch {
                return;
            }
        }
예제 #2
0
        //The search Button. Calls makeFoodRequest from rClient
        private void buttonSearchFood(object sender, EventArgs e)
        {
            RESTClient rClient = new RESTClient();

            rClient.endPoint = "https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/food/products/search?query=" + textBoxFood.Text + "&offset=0&number=10&maxCalories=" + textBoxMaxCalories.Text + "&minProtein=" + textBoxMinProtein.Text + "&maxProtein=" + textBoxMaxProtein.Text + "&minFat=" + textBoxMinFat.Text + "&maxFat=" + textBoxMaxFat.Text + "&minCarbs=" + textBoxMinCarbs.Text + "&maxCarbs=" + textBoxMaxCarbs.Text + "&minCalories=" + textBoxMinCalories.Text;
            try{
                f = rClient.makeFoodRequest();
                dataGridViewFood.RowTemplate.Height = 150;
                dataGridViewFood.Rows.Clear();
                dataGridViewFood.Refresh();

                for (int i = 0; i < f.Length; i++)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataGridViewFood);
                    row.Cells[0].Value = f[i].getId();
                    row.Cells[1].Value = f[i].getName();
                    row.Cells[2].Value = f[i].getImg();

                    dataGridViewFood.Rows.Add(row);
                }
                int             RowIndex = dataGridViewFood.RowCount - 1;
                DataGridViewRow R        = dataGridViewFood.Rows[RowIndex];
            }catch {
                return;
            }
        }
예제 #3
0
        //Searches for a recipe given the parameters.
        private void buttonRecipeSearch(object sender, EventArgs e)
        {
            RESTClient rClient = new RESTClient();

            rClient.endPoint = "https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/search?diet=" + listBoxDiet.GetItemText(listBoxDiet.SelectedItem) + "&excludeIngredients=" + textBoxExIngredients.Text + "&intolerances=" + textBoxIntolarences.Text + "&number=10&offset=0&query=" + textBoxRecipe.Text + "&type=" + listBoxType.GetItemText(listBoxDiet.SelectedItem);
            try{
                Recipe[] re = rClient.makeRecipeRequest();

                dataGridViewRecipe.Rows.Clear();
                dataGridViewRecipe.Refresh();

                for (int i = 0; i < 10; i++)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataGridViewRecipe);
                    row.Cells[0].Value = re[i].getId();
                    row.Cells[1].Value = re[i].getName();
                    row.Cells[2].Value = re[i].getMinutes();
                    row.Cells[3].Value = re[i].getServings();

                    dataGridViewRecipe.Rows.Add(row);
                }
                int             RowIndex = dataGridViewRecipe.RowCount - 1;
                DataGridViewRow R        = dataGridViewRecipe.Rows[RowIndex];
            }catch {
                dataGridViewRecipe.Rows.Clear();
                dataGridViewRecipe.Refresh();
            }
        }
예제 #4
0
        //Some extra information about the given recipe
        private void dataGridViewRecipe_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            RESTClient rClient     = new RESTClient();
            int        rowindex    = dataGridViewRecipe.CurrentCell.RowIndex;
            int        columnindex = dataGridViewRecipe.CurrentCell.ColumnIndex;

            try{
                rClient.endPoint = "https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/" + dataGridViewRecipe.Rows[rowindex].Cells[columnindex].Value.ToString() + "/information";
                RecipeInfo  ri = rClient.makeRecipeInformationRequest();
                Info_Recipe ir = new Info_Recipe();
                ir.ShowDialog();
                getRecipeInfo  = String.Join(",", ri.getIngredients().ToArray());
                getRecipesteps = ri.getSteps().ToString();
            }catch {
                return;
            }
        }
예제 #5
0
        private void dataGridViewFood_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Console.WriteLine("Method call");
            RESTClient rClient     = new RESTClient();
            int        rowindex    = dataGridViewFood.CurrentCell.RowIndex;
            int        columnindex = dataGridViewFood.CurrentCell.ColumnIndex;

            try {
                rClient.endPoint = "https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/food/products/" + dataGridViewFood.Rows[rowindex].Cells[columnindex].Value.ToString();

                Nutrients nutrient = rClient.makeNutrientsRequest();

                NutritionInfo ni = new NutritionInfo();

                ni.setCalories(nutrient.getfoodNutrients()["calories"]);
                ni.setFat(nutrient.getfoodNutrients()["fat"]);
                ni.setProtein(nutrient.getfoodNutrients()["protein"]);
                ni.setCarbs(nutrient.getfoodNutrients()["carbs"]);
                ni.ShowDialog();
            }
            catch
            {
            }
        }