Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
 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));
 }