Beispiel #1
0
        public async Task <IActionResult> Create([Bind("ID,LastName,FirstName,License")] Driver driver)
        {
            if (ModelState.IsValid)
            {
                _context.Add(driver);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(driver));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("ID,Make,Price,DriverID")] Car car)
        {
            if (ModelState.IsValid)
            {
                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DriverID"] = new SelectList(_context.Drivers, "ID", "FirstName", car.DriverID);
            return(View(car));
        }