public async Task <IActionResult> PutContact(int id, Contact contact) { if (id != contact.Id) { return(BadRequest()); } _context.Entry(contact).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPhonebook(long id, Phonebook phonebook) { if (id != phonebook.Id) { return(BadRequest()); } _context.Entry(phonebook).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhonebookExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit(Contact contact) { if (ModelState.IsValid) { db.Entry(contact).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(contact)); }