public async Task <IActionResult> Edit(int id, [Bind("Id,GameId,DatePlayed")] GamePlayed gamePlayed) { if (id != gamePlayed.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gamePlayed); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GamePlayedExists(gamePlayed.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GameId"] = new SelectList(_context.Games, "Id", "Name", gamePlayed.GameId); return(View(gamePlayed)); }
public async Task <GameViewModel> Handle(UpdateGame request, CancellationToken cancellationToken) { var result = await(from pg in _context.PlatformGames join g in _context.Games on pg.GameId equals g.Id where pg.Id == request.Id select new { Game = g, PlatformInfo = pg }).SingleOrDefaultAsync(cancellationToken); if (result != null) { result.Game.Name = request.Name; result.Game.Description = request.Description; _context.Update(result.Game); await _context.SaveChangesAsync(cancellationToken); return(new GameViewModel { Id = request.Id, Name = result.Game.Name, Description = result.Game.Description, Code = result.PlatformInfo.Code, Registered = result.PlatformInfo.Registered }); } return(null); }
public async Task <IActionResult> Edit(int id, [Bind("Id,KeyCode,Type")] GameResultType gameResultType) { if (id != gameResultType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gameResultType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameResultTypeExists(gameResultType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gameResultType)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Player player) { if (id != player.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(player); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlayerExists(player.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(player)); }