public async Task <IActionResult> Edit(int id, [Bind("Id,ClienteId,VeiculoId,Inicio,Termino")] TbLocacoes tbLocacoes) { if (id != tbLocacoes.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tbLocacoes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TbLocacoesExists(tbLocacoes.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClienteId"] = new SelectList(_context.Set <TbClientes>(), "Id", "Nome", tbLocacoes.ClienteId); ViewData["VeiculoId"] = new SelectList(_context.Set <TbVeiculo>(), "Id", "Placa", tbLocacoes.VeiculoId); return(View(tbLocacoes)); }
public async Task <IActionResult> Create([Bind("Id,ClienteId,VeiculoId,Inicio,Termino")] TbLocacoes tbLocacoes) { if (ModelState.IsValid) { _context.Add(tbLocacoes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClienteId"] = new SelectList(_context.Set <TbClientes>(), "Id", "Nome", tbLocacoes.ClienteId); ViewData["VeiculoId"] = new SelectList(_context.Set <TbVeiculo>(), "Id", "Placa", tbLocacoes.VeiculoId); return(View(tbLocacoes)); }