Exemplo n.º 1
0
        public IActionResult Edit(int id, [Bind("Id,Nome,Descricao,Tipo,Fabricante")] Mercadoria mercadoria)
        {
            if (id != mercadoria.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repo.Update(mercadoria);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_repo.MercadoriaExists(mercadoria.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(BadRequest());
            }
            //  return View(mercadoria);
        }