コード例 #1
0
 public ActionResult Edit([Bind(Include = "VehicleTypeId,VehicleTypeName,CreateDate,EditDate")] VehicleType vehicleType)
 {
     try {
         if (ModelState.IsValid)
         {
             db.Entry(vehicleType).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(vehicleType));
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         return(View("Error", new HandleErrorInfo(ex, "VehicleTypesController", "Edit")));
     }
 }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "ModelId,EngineSize,NumberOfDoors,Colour,VehicleTypeId,CreateDate,EditDate")] Model model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(model).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.VehicleTypeId = new SelectList(db.VehicleTypes, "VehicleTypeId", "VehicleTypeName", model.VehicleTypeId);
         return(View(model));
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         return(View("Error", new HandleErrorInfo(ex, "ModelsController", "Edit")));
     }
 }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "VehicleId,MakeId,ModelId,Year,Price,Cost,SoldDate,isSold,CreateDate,EditDate")] Vehicle vehicle)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(vehicle).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.MakeId  = new SelectList(db.Makes, "MakeId", "Name", vehicle.MakeId);
         ViewBag.ModelId = new SelectList(db.Models, "ModelId", "ModelId", vehicle.ModelId);
         return(View(vehicle));
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         return(View("Error", new HandleErrorInfo(ex, "VehiclesController", "Edit")));
     }
 }