Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Preco,Nome,Descricao,Desconto,Estoque,Id_Marca,Id_Categoria")] Produto produto)
        {
            if (id != produto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(produto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProdutoExists(produto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(produto));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Email,Senha")] Administrador administrador)
        {
            if (id != administrador.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(administrador);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdministradorExists(administrador.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(administrador));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ProdutoId,PedidoId")] ProdutoPedido produtoPedido)
        {
            if (id != produtoPedido.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(produtoPedido);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProdutoPedidoExists(produtoPedido.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PedidoId"]  = new SelectList(_context.Pedido, "Id", "Id", produtoPedido.PedidoId);
            ViewData["ProdutoId"] = new SelectList(_context.Produto, "Id", "Id", produtoPedido.ProdutoId);
            return(View(produtoPedido));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] Categoria categoria)
        {
            if (id != categoria.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoria);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoriaExists(categoria.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoria));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Total,Prazo,Id_Cliente,Codigo_Rastreamento,Status")] Pedido pedido)
        {
            if (id != pedido.Id)
            {
                return(NotFound());
            }

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