public async Task <IActionResult> Edit(int id, [Bind("Id,FabricanteId,Nome")] ModeloCar modeloCar)
        {
            if (id != modeloCar.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _modeloCarService.UpdateAsync(modeloCar);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ModeloCarExists(modeloCar.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FabricanteId"] = new SelectList(await _fabricanteService.FindAllAsync(), "Id", "Nome", modeloCar.FabricanteId);
            return(View(modeloCar));
        }
        public async Task <IActionResult> Create([Bind("Id,FabricanteId,Nome")] ModeloCar modeloCar)
        {
            if (ModelState.IsValid)
            {
                await _modeloCarService.AddAsync(modeloCar);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FabricanteId"] = new SelectList(await _fabricanteService.FindAllAsync(), "Id", "Nome", modeloCar.FabricanteId);
            return(View(modeloCar));
        }
        public async Task <IActionResult> Create([Bind("Id,FabricanteId,Nome")] 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));
        }
 internal async Task UpdateAsync(ModeloCar modeloCar)
 {
     _context.Update(modeloCar);
     await _context.SaveChangesAsync();
 }
 internal async Task AddAsync(ModeloCar modeloCar)
 {
     _context.Add(modeloCar);
     await _context.SaveChangesAsync();
 }