コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Marca")] TbMarcaVeiculo tbMarcaVeiculo)
        {
            if (id != tbMarcaVeiculo.Id)
            {
                return(NotFound());
            }

            tbMarcaVeiculo.Marca = tbMarcaVeiculo.Marca.ToUpper();

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tbMarcaVeiculo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TbMarcaVeiculoExists(tbMarcaVeiculo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tbMarcaVeiculo));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Marca")] TbMarcaVeiculo tbMarcaVeiculo)
        {
            tbMarcaVeiculo.Marca = tbMarcaVeiculo.Marca.ToUpper();

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tbMarcaVeiculo));
        }