public ActionResult CreateCar() { VehicleAndCarViewModel model = new VehicleAndCarViewModel() { ListFuelType = _fuelTypeDal.GetFuelTypes(), ListGearType = _gearTypeDal.GetGearTypes(), ListVehicleType = _vehicleTypeDal.GetVehicleTypes() }; return(View(model)); }
public ActionResult CreateCar(VehicleAndCarViewModel model, HttpPostedFileBase CarsPhoto) { if (CarsPhoto != null) { FileInfo fi = new FileInfo(CarsPhoto.FileName); string type = Path.GetExtension(CarsPhoto.FileName); string name = model.Vehicle.VehicleId + type; //string adi = user.Deu_Bbt_Ogrenci_Numarasi + tip; var _path = Path.Combine(Server.MapPath("~/CarsPhotos/"), name); CarsPhoto.SaveAs(_path); model.Vehicle.VehiclePhoto = name; } if (ModelState.IsValid) { TempData["success"] = model.Vehicle.LicensePlate + " plakalı otomobil başarıyla oluşturuldu."; _carDal.SaveCar(model.Car, model.Vehicle); } return(RedirectToAction("CreateCar", "AdminPanel")); }