public async Task <IActionResult> PutPlayer([FromRoute] int id, [FromBody] Player player) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != player.Id) { return(BadRequest()); } _context.Update(player); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlayerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,ImageURL,ReleaseYear,AddedByUser,DateAdded")] Game game) { if (id != game.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(game); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameExists(game.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(game)); }