public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Email,CPF")] 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)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Preco,Quantidade,ClienteId")] 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["ClienteId"] = new SelectList(_context.Cliente, "Id", "Email", pedido.ClienteId); return(View(pedido)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Preco,Quantidade")] 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)); }