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

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(itens);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItensExists(itens.PedidoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PedidoId"]  = new SelectList(_context.Pedidos, "Id", "Id", itens.PedidoId);
            ViewData["ProdutoId"] = new SelectList(_context.Produtos, "Id", "Id", itens.ProdutoId);
            return(View(itens));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,PrecoUnitario,Nome")] 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));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Cpf,Email")] Usuario usuario)
        {
            if (id != usuario.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usuario);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuarioExists(usuario.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(usuario));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Data,UsuarioId,QtdeItens,ValorTotal")] 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)));
            }
            ViewData["UsuarioId"] = new SelectList(_context.Usuarios, "Id", "Id", pedido.UsuarioId);
            return(View(pedido));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Nascimento,Altura")] Cliente cliente)
        {
            if (id != cliente.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
コード例 #6
0
 public void editar(Categoria categoria)
 {
     if (_context.Categoria.Any(cat => cat.Id == categoria.Id))
     {
         try
         {
             _context.Update(categoria);
             _context.SaveChanges();
         }
         catch (Exception e)
         {
         }
     }
 }
 public void Editar(Produto produto)
 {
     if (_context.Produto.Any(prod => prod.Id == produto.Id))
     {
         try
         {
             _context.Update(produto);
             _context.SaveChanges();
         }
         catch (Exception e)
         {
         }
     }
 }