public ActionResult Edit(Entry newEntry) { var entry = db.Entries.Find(newEntry.ID); newEntry.Patch(entry); ModelState.Clear(); if (TryValidateModel(entry)) { db.Entry(entry).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(entry); }
public object Patch(int id, Entry newEntry) { var entry = db.Entries.Find(id); if (entry == null) { return HttpNotFound(); } newEntry.Patch(entry); ModelState.Clear(); ValidateModel(entry); if (ModelState.IsValid) { db.Entry(entry).State = EntityState.Modified; db.SaveChanges(); return entry; } return new HttpException(400, "model state was not vallid"); }