예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,MarcaId,Modelo")] TbModeloVeiculo tbModeloVeiculo)
        {
            if (id != tbModeloVeiculo.Id)
            {
                return(NotFound());
            }

            tbModeloVeiculo.Modelo = tbModeloVeiculo.Modelo.ToUpper();

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tbModeloVeiculo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TbModeloVeiculoExists(tbModeloVeiculo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MarcaId"] = new SelectList(_context.Set <TbMarcaVeiculo>(), "Id", "Marca", tbModeloVeiculo.MarcaId);
            return(View(tbModeloVeiculo));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,MarcaId,Modelo")] TbModeloVeiculo tbModeloVeiculo)
        {
            tbModeloVeiculo.Modelo = tbModeloVeiculo.Modelo.ToUpper();

            if (ModelState.IsValid)
            {
                _context.Add(tbModeloVeiculo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MarcaId"] = new SelectList(_context.Set <TbMarcaVeiculo>(), "Id", "Marca", tbModeloVeiculo.MarcaId);
            return(View(tbModeloVeiculo));
        }