public ActionResult Create(Ingredient ingredient)
        {
            if (ModelState.IsValid)
            {
                db.Ingredients.AddObject(ingredient);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(ingredient);
        }
        public ActionResult Create(Ingredient ingredient)
        {
            if (ModelState.IsValid)
            {
                db.Ingredients.AddObject(ingredient);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.IngredientTypeId = new SelectList(db.IngredientTypes, "IngredientTypeId", "IngredientTypeName", ingredient.IngredientTypeId);
            return View(ingredient);
        }
 public ActionResult Edit(Ingredient ingredient)
 {
     if (ModelState.IsValid)
     {
         db.Ingredients.Attach(ingredient);
         db.ObjectStateManager.ChangeObjectState(ingredient, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(ingredient);
 }
Esempio n. 4
0
 /// <summary>
 /// Create a new Ingredient object.
 /// </summary>
 /// <param name="ingredientId">Initial value of the IngredientId property.</param>
 /// <param name="ingredientTypeId">Initial value of the IngredientTypeId property.</param>
 public static Ingredient CreateIngredient(global::System.Int32 ingredientId, global::System.Int32 ingredientTypeId)
 {
     Ingredient ingredient = new Ingredient();
     ingredient.IngredientId = ingredientId;
     ingredient.IngredientTypeId = ingredientTypeId;
     return ingredient;
 }
Esempio n. 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Ingredients EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIngredients(Ingredient ingredient)
 {
     base.AddObject("Ingredients", ingredient);
 }
 public ActionResult Edit(Ingredient ingredient)
 {
     if (ModelState.IsValid)
     {
         db.Ingredients.Attach(ingredient);
         db.ObjectStateManager.ChangeObjectState(ingredient, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.IngredientTypeId = new SelectList(db.IngredientTypes, "IngredientTypeId", "IngredientTypeName", ingredient.IngredientTypeId);
     return View(ingredient);
 }