public ActionResult DeleteConfirmed(int id) { Food.Models.Food food = db.Foods.Find(id); db.Foods.Remove(food); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Name,Type")] Food.Models.Food food) { if (ModelState.IsValid) { db.Entry(food).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(food)); }
public ActionResult Create([Bind(Include = "Id,Name,Type")] Food.Models.Food food) { if (ModelState.IsValid) { db.Foods.Add(food); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(food)); }
// GET: Foods/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Food.Models.Food food = db.Foods.Find(id); if (food == null) { return(HttpNotFound()); } return(View(food)); }