public async Task <IHttpActionResult> Put(ToDoItem item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await ToDoItemExist(item.Id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutToDoItem(long id, ToDoItem toDoItem) { if (id != toDoItem.Id) { return(BadRequest()); } _context.Entry(toDoItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToDoItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//[ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "ID,Description,DateCreated,DateDeadline,Completed,Owner")] ToDoItem toDoItem) { if (ModelState.IsValid) { db.Entry(toDoItem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(toDoItem)); }
public ActionResult Edit([Bind(Include = "ID,UserName,Email,EnableNotifications")] UserProfile userProfile) { if (ModelState.IsValid) { db.Entry(userProfile).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "ToDoItems")); } return(View(userProfile)); }
public ToDoItem updateItem(ToDoItem item) { _context.Entry(item).State = EntityState.Modified; _context.SaveChanges(); return(item); }