public ActionResult SaveChanges(item updatedItem) //update { gccoffeeshopEntities ORM = new gccoffeeshopEntities(); //find the old record that you're updating item OldRecord = ORM.items.Find(updatedItem.itemid); //ToDo: check for null!!!!!! //if (OldRecord == null) //{ // return View("Index"); //} //don't need to update itemid because that stays the same OldRecord.name = updatedItem.name; OldRecord.description = updatedItem.description; OldRecord.quantity = updatedItem.quantity; OldRecord.price = updatedItem.price; //need to change the state of the record from original to the modified state!! ORM.Entry(OldRecord).State = System.Data.Entity.EntityState.Modified; ORM.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult SaveChanges(item UpdatedItem) { gccoffeeshopEntities ORM = new gccoffeeshopEntities(); //need this is every operation that takes in information //find the old record item OldRecord = ORM.items.Find(UpdatedItem.itemid); //ToDo check for null OldRecord.name = UpdatedItem.name; OldRecord.description = UpdatedItem.description; OldRecord.quantity = UpdatedItem.quantity; OldRecord.price = UpdatedItem.price; ORM.Entry(OldRecord).State = System.Data.Entity.EntityState.Modified; ORM.SaveChanges(); return(RedirectToAction("Index")); }