public async Task <IActionResult> Edit(int id, [Bind("ID,data,aprovado,responsavel")] AnaliseQualidade analiseQualidade, IFormCollection collection) { int idOrdem = Convert.ToInt16(collection["Ordem"]); if (id != analiseQualidade.ID) { return(NotFound()); } if (ModelState.IsValid) { try { var ord = await _context.Ordem.FindAsync(idOrdem); analiseQualidade.ordem = ord; _context.Update(analiseQualidade); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnaliseQualidadeExists(analiseQualidade.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(analiseQualidade)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,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)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,nome,telefone,endereco")] 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,data,hora,qdte")] Ordem ordem, IFormCollection collection) { if (id != ordem.ID) { return(NotFound()); } int idProduto = Convert.ToInt16(collection["Produto"]); int idCliente = Convert.ToInt16(collection["Cliente"]); if (ModelState.IsValid) { try { var prod = await _context.Produto.FindAsync(idProduto); ordem.produto = prod; var cli = await _context.Cliente.FindAsync(idCliente); ordem.cliente = cli; _context.Update(ordem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrdemExists(ordem.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(ordem)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,nome,tamanho,qtde")] Embalagem embalagem, IFormCollection collection) { if (id != embalagem.ID) { return(NotFound()); } int idProduto = Convert.ToInt16(collection["Produto"]); int idFornecedor = Convert.ToInt16(collection["Fornecedor"]); if (ModelState.IsValid) { try { var prod = await _context.Produto.FindAsync(idProduto); embalagem.produto = prod; var forn = await _context.Fornecedor.FindAsync(idFornecedor); embalagem.fornecedor = forn; _context.Update(embalagem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmbalagemExists(embalagem.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(embalagem)); }