Пример #1
0
        public async Task <IActionResult> Create([Bind("MarcaId,Nome")] Marca marca)
        {
            if (ModelState.IsValid)
            {
                _context.Add(marca);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(marca));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("ModeloId,Nome,Ano,MarcaId")] Modelo modelo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(modelo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MarcaId"] = new SelectList(_context.Marcas, "MarcaId", "MarcaId", modelo.MarcaId);
            return(View(modelo));
        }