public ActionResult DeleteConfirmedEdit(int id)
        {
            using (DBingredient context = new DBingredient())
            {
                int?recipeIDInput = (int)TempData["RecipeID"];

                if (recipeIDInput == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                Recipe recipe = context.Recipes.Find(recipeIDInput);

                if (recipe == null)
                {
                    return(HttpNotFound());
                }

                RecipeIngredient ingredient = context.TotalRecipeIngredients.Find(id);
                recipe.RecipeIngredients.Remove(ingredient);
                context.Entry(recipe).State = EntityState.Modified;
                context.SaveChanges();

                context.TotalRecipeIngredients.Remove(ingredient);
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult AddInventory([Bind(Include = "InventoryingredientID,ingredient,Hoeveelheid,Eenheid")] InventoryIngredient inventoryIngredient)
        {
            using (DBingredient context = new DBingredient())
            {
                if (ModelState.IsValid)
                {
                    User user      = (User)Session["user"];
                    int  UserID    = user.UserID;
                    User indexUser = context.Users.Find(UserID);
                    //int inventoryID = indexUser.inventory.InventoryID;

                    //Inventory inventory = context.Inventories.Find(inventoryID);
                    Ingredient ig = context.Ingredients.Find(inventoryIngredient.ingredient.ingredientID);
                    inventoryIngredient.ingredient = ig;
                    context.InventoryIngredients.Add(inventoryIngredient);
                    context.SaveChanges();

                    indexUser.inventory.InventoryIngredients.Add(inventoryIngredient);
                    context.Entry(indexUser.inventory).State = EntityState.Modified;
                    context.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(inventoryIngredient));
            }
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "ingredientID,name,merk")] Ingredient ingredient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ingredient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ingredient));
 }
 public ActionResult Edit([Bind(Include = "InventoryingredientID,Ingredient,Hoeveelheid,Eenheid")] InventoryIngredient inventoryIngredient)
 {
     if (ModelState.IsValid)
     {
         Ingredient ig = db.Ingredients.Find(inventoryIngredient.ingredient.ingredientID);
         inventoryIngredient.ingredient      = ig;
         db.Entry(inventoryIngredient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(inventoryIngredient));
 }
 public ActionResult Edit([Bind(Include = "BoodschapIngredientID,Ingredient,Hoeveelheid,Eenheid")] BoodschapIngredient boodschapIngredient)
 {
     using (DBingredient context = new DBingredient())
     {
         if (ModelState.IsValid)
         {
             Ingredient ig = context.Ingredients.Find(boodschapIngredient.ingredient.ingredientID);
             boodschapIngredient.ingredient           = ig;
             context.Entry(boodschapIngredient).State = EntityState.Modified;
             context.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(boodschapIngredient));
     }
 }