public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Test test) { if (id != test.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(test); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TestExists(test.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(test)); }
public async Task <IActionResult> Edit(int id, [Bind("TbClienteId,TbFilmeId,DataLocacao,DataDevolucao,Id")] TbLocacao tbLocacao) { if (id != tbLocacao.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tbLocacao); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TbLocacaoExists(tbLocacao.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TbClienteId"] = new SelectList(_context.TbCliente, "Id", "Cpf", tbLocacao.TbClienteId); ViewData["TbFilmeId"] = new SelectList(_context.TbFilme, "Id", "Filme", tbLocacao.TbFilmeId); return(View(tbLocacao)); }