Exemplo n.º 1
0
        public void GetTags_ReturnsAllTagRecipes_TagList()
        {
            //Arrange
            Tag testTag1 = new Tag("Artichoke");

            testTag1.Save();

            Tag testTag2 = new Tag("Red Peppers");

            testTag2.Save();

            Recipe testRecipe1 = new Recipe("Roasted Artichokes", "5", "cook");

            testRecipe1.Save();


            //Act
            testRecipe1.AddTag(testTag1);
            testRecipe1.AddTag(testTag2);
            List <Tag> result   = testRecipe1.GetTags();
            List <Tag> testList = new List <Tag> {
                testTag1, testTag2
            };

            //Assert
            Assert.AreEqual(testList.Count, result.Count);
            // CollectionAssert.AreEqual(testList, result);
        }
Exemplo n.º 2
0
        public void AddTag_AddsTagToRecipe_TagList()
        {
            //Arrange
            Tag testTag1 = new Tag("Olive Oil");

            testTag1.Save();
            Tag testTag2 = new Tag("Red Peppers");

            testTag2.Save();

            Recipe firstRecipe = new Recipe("Roasted Artichokes", "5", "cook");

            firstRecipe.Save();

            List <Tag> testList = new List <Tag> {
                testTag1, testTag2
            };

            //Act
            firstRecipe.AddTag(testTag1);
            firstRecipe.AddTag(testTag2);
            List <Tag> result = firstRecipe.GetTags();

            //Assert
            Assert.AreEqual(testList.Count, result.Count);
        }
Exemplo n.º 3
0
 public async Task <IActionResult> OnPostAddTag(string newTag, string id)
 {
     try {
         InitializeAll(id);
         Inf.AddTag(Recipe, newTag);
         Recipe.AddTag(newTag);
         return(Page());
     } catch (Exception) {
         HttpContext.Session.SetString("errorMsg", "שגיאה בהוספת הטאג");
         return(RedirectToPage("ErrorPage"));
     }
 }
Exemplo n.º 4
0
        public ActionResult Create(string name, string ingredients, string tags)
        {
            Recipe newRecipe = new Recipe(name, 0, ingredients);

            newRecipe.Save();
            if (tags != null)
            {
                Tag newTag = new Tag(tags, newRecipe.Id);
                newTag.Save();
                newRecipe.AddTag(newTag);
            }

            return(RedirectToAction("MethodForm", "Methods", new { id = newRecipe.Id }));
        }
Exemplo n.º 5
0
        public ActionResult Create()
        {
            Recipe newRecipe = new Recipe(
                Request.Form["name"],
                Request.Form["rating"],
                Request.Form["instruction"]
                );

            newRecipe.Save();
            Console.WriteLine(newRecipe.GetRating());
            Ingredient newIngredient = new Ingredient(Request.Form["ingredientList"]);

            newRecipe.AddIngredient(newIngredient);
            Tag newTag = new Tag(Request.Form["tagList"]);

            newRecipe.AddTag(newTag);

            List <Recipe> allRecipes = Recipe.GetAll();

            return(View("Index", allRecipes));
        }
Exemplo n.º 6
0
        private void Button_Save_Click(object sender, EventArgs e)
        {
            var recipe = new Recipe();

            recipe.Name        = TextBox_RecipeName.Text;
            recipe.Creator     = TextBox_Creator.Text;
            recipe.Description = TextBox_Description.Text;
            var stepDataSet           = DataGrid_Steps;
            var tagStringWithoutSpace = RemoveWhiteSpace(TextBox_Tags.Text);
            var tags = tagStringWithoutSpace.Split(';');

            foreach (String tag in tags)
            {
                recipe.AddTag(tag);
            }
            foreach (DataGridViewRow row in stepDataSet.Rows)
            {
                if (row.Cells[0].Value != null)
                {
                    String stepDescription  = (String)row.Cells[0].Value;
                    String ingredientString = (String)row.Cells[1].Value;
                    int    timer            = Int32.Parse((String)row.Cells[2].Value);
                    String timeUnit         = row.Cells[3].Value.ToString();

                    Step newStep = new Step();
                    newStep.Description = stepDescription;
                    newStep.SetTimer(timer, GetTimeUnit(timeUnit));
                    if (ingredientString != null)
                    {
                        ProcessIngredient(ref newStep, ingredientString);
                    }
                    recipe.AddStep(newStep);
                }
            }
            recipe.ImagePath = Label_ImagePath.Text;
            var rm = new RecipeManagerAdmin();

            rm.StoreRecipe(recipe);
            MessageBox.Show("Recipe saved!");
        }