public ActionResult Create([Bind(Include = "BrandID,BrandName")] Brand brand) { if (ModelState.IsValid) { db.Brands.Add(brand); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(brand)); }
public ActionResult Create([Bind(Include = "VehicleID,LicencePlate,Color,EngineCapacity,Fuel,BrandID")] Vehicle vehicle) { if (ModelState.IsValid) { db.Vehicles.Add(vehicle); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BrandID = new SelectList(db.Brands, "BrandID", "BrandName", vehicle.BrandID); return(View(vehicle)); }