public async Task <IActionResult> PutKey(string id, Key key) { if (id != key.key) { return(BadRequest()); } _context.Entry(key).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KeyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit(int id, Key editKey) { try { editKey.Updated = DateTime.Now; using (var context = new KeyContext()) { context.Entry(editKey).State = EntityState.Modified; context.SaveChanges(); } return(RedirectToAction("Index")); } catch (Exception e) { return(View("Error", e)); } }