public async Task <IActionResult> Edit(int id, [Bind("FavoriteId,AdventureId,UserId")] FavoriteEvents favoriteEvents) { if (id != favoriteEvents.FavoriteId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(favoriteEvents); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FavoriteEventsExists(favoriteEvents.FavoriteId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AdventureId"] = new SelectList(_context.AdventuresTable, "AdventureId", "AdventureId", favoriteEvents.AdventureId); ViewData["UserId"] = new SelectList(_context.User, "Id", "Id", favoriteEvents.UserId); return(View(favoriteEvents)); }
// GET: FavoriteEvents/Create public async Task <IActionResult> Create(int id, string userid) { //ViewData["AdventureId"] = id; //ViewData["UserId"] = userid; FavoriteEvents favorite = new FavoriteEvents(); favorite.UserId = userid; favorite.AdventureId = id; _context.Add(favorite); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); }