コード例 #1
0
        public async Task <IActionResult> Create([Bind("CarBrandID,CarBrandName")] CarBrand carBrand)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carBrand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(carBrand));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("CarModelID,CarBrandFK,CarModelName")] CarModel carModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarBrandFK"] = new SelectList(_context.CarBrand, "CarBrandID", "CarBrandName", carModel.CarBrandFK);
            return(View(carModel));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("CarID,CarModelFK,Year,Price,Mileage")] Car car)
        {
            if (ModelState.IsValid)
            {
                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarModelFK"] = new SelectList(_context.CarModel, "CarModelID", "CarModelName", car.CarModelFK);
            return(View(car));
        }