public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,GameId,DatePurchased")] PurchasedGames purchasedGames) { if (id != purchasedGames.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(purchasedGames); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PurchasedGamesExists(purchasedGames.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GameId"] = new SelectList(_context.Games, "Id", "Description", purchasedGames.GameId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Displayname", purchasedGames.UserId); return(View(purchasedGames)); }
public async Task <IActionResult> Create([Bind("Id,UserId,GameId,DatePurchased")] PurchasedGames purchasedGames) { if (ModelState.IsValid) { _context.Add(purchasedGames); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GameId"] = new SelectList(_context.Games, "Id", "Description", purchasedGames.GameId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Displayname", purchasedGames.UserId); return(View(purchasedGames)); }