public ActionResult Create(Cake cake) { if (ModelState.IsValid) { try{ db.Cakes.AddObject(cake); db.SaveChanges(); return RedirectToAction("Index"); } catch (System.Data.Entity.Validation.DbEntityValidationException) { return RedirectToAction("Index"); } } return View(cake); }
/// <summary> /// Create a new Cake object. /// </summary> /// <param name="cakeID">Initial value of the CakeID property.</param> public static Cake CreateCake(global::System.Int32 cakeID) { Cake cake = new Cake(); cake.CakeID = cakeID; return cake; }
public ActionResult Edit(Cake cake) { if (ModelState.IsValid) { db.Cakes.Attach(cake); db.ObjectStateManager.ChangeObjectState(cake, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } return View(cake); }
/// <summary> /// Deprecated Method for adding a new object to the Cakes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCakes(Cake cake) { base.AddObject("Cakes", cake); }