public async Task <IActionResult> Edit(int id, [Bind("ReservaID,ReservaParaDia,GuiaID,TuristaID,TrilhoID")] ReservaGuia reservaGuia) { if (id != reservaGuia.ReservaID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(reservaGuia); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservaGuiaExists(reservaGuia.ReservaID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GuiaID"] = new SelectList(_context.Guias, "GuiaID", "Nome", reservaGuia.GuiaID); ViewData["TrilhoID"] = new SelectList(_context.Trilhos2, "TrilhoID", "Nome", reservaGuia.TrilhoID); ViewData["TuristaID"] = new SelectList(_context.Turistas, "TuristaID", "Nome", reservaGuia.TuristaID); return(View(reservaGuia)); }
public async Task <IActionResult> Create([Bind("ReservaID,ReservaParaDia,GuiaID,TuristaID,TrilhoID")] ReservaGuia reservaGuia) { if (ModelState.IsValid) { _context.Add(reservaGuia); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GuiaID"] = new SelectList(_context.Guias, "GuiaID", "Nome", reservaGuia.GuiaID); ViewData["TrilhoID"] = new SelectList(_context.Trilhos2, "TrilhoID", "Nome", reservaGuia.TrilhoID); ViewData["TuristaID"] = new SelectList(_context.Turistas, "TuristaID", "Nome", reservaGuia.TuristaID); return(View(reservaGuia)); }