public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,Lastname")] Contact contact) { if (id != contact.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(contact); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(contact.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(contact)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Address,City,Subregion,PostalCode,Phone,Email")] Contact contact) { if (id != contact.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(contact); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(contact.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(contact)); }
public async Task <IActionResult> Edit(Contact contact) { if (ModelState.IsValid) { _context.Update(contact); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(contact)); }
public void Update(Contact contact) { _context.Update(contact); _context.SaveChanges(); }