public IActionResult Shoot([FromRoute] int playerId, [FromQuery] int?x, [FromQuery] int?y) { var player = _ctx.Players .Include(p => p.Game) .ThenInclude(g => g.Players) .SingleOrDefault(p => p.PlayerId == playerId); if (player == null) { return(NotFound("Spilleren findes ikke")); } if (!x.HasValue || !y.HasValue) { return(BadRequest("x og y skal angives")); } var game = new BattleshipGame(player.Game); bool isWinner = game.Shoot(player, x.Value, y.Value); if (isWinner) { player.Game.WinnerId = player.PlayerId; } _ctx.SaveChanges(); if (isWinner) { return(RedirectToAction(nameof(Winner), new { playerId = player.PlayerId })); } return(RedirectToAction(nameof(Wait), new { playerId = player.PlayerId })); }