Exemplo n.º 1
0
        public async Task <IActionResult> Create(CarsCreateViewModel createModel)
        {
            if (ModelState.IsValid)
            {
                Car car = new Car
                {
                    Model  = createModel.Model,
                    Brand  = createModel.Brand,
                    Engine = createModel.Engine,
                    Year   = createModel.Year
                };

                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(createModel));
        }
Exemplo n.º 2
0
        // GET: Cars/Create
        public IActionResult Create()
        {
            CarsCreateViewModel model = new CarsCreateViewModel();

            return(View(model));
        }