public ActionResult Create([Bind(Include = "ID,Model,MaxSpeed")] Car car)
        {
            if (ModelState.IsValid)
            {
                db.Cars.Add(car);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(car));
        }
Ejemplo n.º 2
0
        public void Initialize()
        {
            context.Database.EnsureCreated();
            if (context.Cars.Any())
            {
                return;
            }

            context.Cars.Add(new CarCore()
            {
                MaxSpeed = 100,
                Model    = "Good old car"
            });
            context.Cars.Add(new CarCore()
            {
                MaxSpeed = 150,
                Model    = "Premium car"
            });
            context.Cars.Add(new CarCore()
            {
                MaxSpeed = 190,
                Model    = "Luxury car"
            });
            context.SaveChanges();
        }