Exemplo n.º 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));
        }
Exemplo n.º 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));
        }