public ActionResult Create(VehicleViewModel model) { SetActiveMenuItem(); TempData.Keep(); //Repopulate the dropdown lists of vehicle attributes without asking SQL again model.VehicleManufacturerList = (SelectList)TempData["VehicleManufacturerList"]; model.VehicleModelList = (SelectList)TempData["VehicleModelList"]; model.VehicleTransmissionList = (SelectList)TempData["VehicleTransmissionList"]; model.VehicleGroupList = (SelectList)TempData["VehicleGroupList"]; model.VehicleFuelList = (SelectList)TempData["VehicleFuelList"]; if (!ModelState.IsValid) { return(View(model)); } try { var FullName = Request.Cookies["userInfo"]["FullName"]; //Now update the record VehicleBLL.AddNewVehicle(model.ModelID, model.RegistrationNumber, model.CurrentMileage, model.TransmissionID, model.VehicleGroupID, model.FuelID, FullName, out int returnValue); //Take our ID with us to the confirmation form ViewBag.Id = returnValue; //Clear any temp data TempData.Clear(); //Determine the kind of SQL transaction we have performed ViewBag.Message = "added"; //We can now safely go to the confirmation view return(View("AddUpdateConfirm")); } catch (Exception ex) { TempData["ErrorMessage"] = ex.Message; return(Redirect("~/Admin/Home/Error")); } }