0
我有這個卡車維修計劃系統,現在這是我的更新卡車詳細控制器,在更新此我還必須更新卡車的當前運行,並且卡車當前運行將轉到最後一次運行?我很難弄明白。這是我的代碼:MVC更新詳細信息控制器
public ActionResult UpdateTruck(TruckDetails u, int id)
{
var updateTruck = db.trucks.FirstOrDefault(s => s.id == id);
if (updateTruck == null)
return View(u);
var lastrun = db.trucks.Select(s => s.current_run); // This is my problem, getting the current run value from the database
updateTruck.registration_no = u.reg_no;
updateTruck.make = u.make;
updateTruck.model = u.model;
updateTruck.engine_no = u.engine_no;
updateTruck.chassis_no = u.chassis_no;
updateTruck.driver_name = u.driver_name;
updateTruck.driver_no = u.driver_no;
updateTruck.is_updated = DateTime.Now;
updateTruck.current_run = u.current_run;
updateTruck.last_run = lastrun;
if (ModelState.IsValid)
{
db.SaveChanges();
return View(u);
}
return View(u);
}
預先感謝您
我不知道您在找什麼建議 – Jonesopolis