public void EditFood(Food food) { var dbFood = _db.Foods.Find(food.Id); if ( dbFood != null ) { _db.Entry(dbFood).CurrentValues.SetValues(food); _db.SaveChanges(); } }
public ActionResult Create(Food f) { if (ModelState.IsValid) { _service.AddFood(f); return RedirectToAction("Create"); } return View(f); }
public void AddFood(Food food) { _db.Foods.Add(food); _db.SaveChanges(); }
public ActionResult Edit(Food f) { _service.EditFood(f); return View("Details", f); }