Beispiel #1
0
        public ActionResult EditPost(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var customerToUpdate = db.Customers.Find(id);

            if (TryUpdateModel(customerToUpdate, "",
                               new string[] { "CustomerID", "CustomerFirst", "CustomerLast", "CustomerAddress", "CustomerEmail" }))
            {
                try
                {
                    db.Entry(customerToUpdate).State = EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                catch (DataException /* dex */)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }
            return(View(customerToUpdate));
        }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "LotID,GoatID,CustomerID,GoatName,CustomerFirst,CustomerLast,LotAddress,LotDescription")] Lot lot)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lot).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(lot));
 }
Beispiel #3
0
 public ActionResult Edit([Bind(Include = "GoatID,GoatName,GoatColor,GoatType,GoatGender")] Goat goat)
 {
     if (ModelState.IsValid)
     {
         db.Entry(goat).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(goat));
 }