public async Task <IActionResult> Create([Bind("Id,Brand_Name")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                _context.Add(brand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(brand));
        }
        public async Task <IActionResult> Create([Bind("Id,Model_Name,BrandId,Start_Date,End_Date")] CarModel carModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"] = new SelectList(_context.Brand, "Id", "Brand_Name", carModel.BrandId);
            return(View(carModel));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("Id,Manufacturing_Date,Comments,Price,BrandId,ModelId")] Car car)
        {
            if (ModelState.IsValid)
            {
                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"] = new SelectList(_context.Brand, "Id", "Brand_Name", car.BrandId);
            ViewData["ModelId"] = new SelectList(_context.CarModel.Where(x => x.BrandId == car.BrandId), "Id", "Model_Name", car.ModelId);
            return(View(car));
        }