Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ModeloId,Nome,Ano,MarcaId")] Modelo modelo)
        {
            if (id != modelo.ModeloId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(modelo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ModeloExists(modelo.ModeloId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MarcaId"] = new SelectList(_context.Marcas, "MarcaId", "MarcaId", modelo.MarcaId);
            return(View(modelo));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("MarcaId,Nome")] Marca marca)
        {
            if (id != marca.MarcaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(marca);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MarcaExists(marca.MarcaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(marca));
        }