public ActionResult AddNewCar(AddNewCar addcar, HttpPostedFileBase car_photo) { if (ModelState.IsValid) { if (car_photo != null) { FileUpload.DeleteFile(addcar.Photo); addcar.Photo = FileUpload.UploadFile(car_photo); } Auto auto = new Auto(); addcar.AssignTo(auto); AutoAPI.AddAuto(auto); return RedirectToAction("ActionAddCarSuccess", "Administration"); } return RedirectToAction("ActionAddCarSuccess", "Administration"); }
public ActionResult AddNewCar(Auto aut) { IList<ModelCar> ModelList = ModelCarAPI.GetModels(); IEnumerable<SelectListItem> selectList = from c in ModelList select new SelectListItem { Text = c.ModelAuto, Value = c.ID.ToString("b"), Selected = (c.ID == aut.ModelID) }; ViewData["TestList2"] = selectList; var model = new AddNewCar(); model.ModelTypeOptions = selectList; return View(model); }