public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,FabricanteId")] Modelocar modelocar) { if (id != modelocar.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(modelocar); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ModelocarExists(modelocar.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FabricanteId"] = new SelectList(_context.Fabricante, "Id", "Id", modelocar.FabricanteId); return(View(modelocar)); }
public async Task <IActionResult> Create([Bind("Id,Nome,FabricanteId")] Modelocar modelocar) { if (ModelState.IsValid) { _context.Add(modelocar); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FabricanteId"] = new SelectList(_context.Fabricante, "Id", "Id", modelocar.FabricanteId); return(View(modelocar)); }