public ActionResult Edit([Bind(Include = "ID,FirstName,LastName")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit([Bind(Include = "OrderID,UserID,TrackingID,City,State,Zip")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserID = new SelectList(db.Users, "ID", "FirstName", order.UserID); return(View(order)); }
public async Task <int> UpdateOrder(OrderItem order) { var orderToUpdate = await _context.Orders.SingleOrDefaultAsync(s => s.ID == order.ID); _context.Entry(orderToUpdate).State = EntityState.Modified; orderToUpdate.Name = order.Name; orderToUpdate.StreetAddress = order.StreetAddress; orderToUpdate.City = order.City; orderToUpdate.State = order.State; orderToUpdate.ZipCode = order.ZipCode; orderToUpdate.TrackingID = order.TrackingID; orderToUpdate.UserID = order.UserID; return(await _context.SaveChangesAsync()); }
public ActionResult Edit(ApplicationUser user) { if (user == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException ex) { //Log the error ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(user)); }