public async Task <IActionResult> OnPostComputerMoveAsync(int id) { if (!ModelState.IsValid) { return(RedirectToPage("PlayGame", new { id })); } var battleShipsSave = await _appDbContext.BattleShipsSaves.FirstOrDefaultAsync(e => e.Id == id); BattleShips = new BattleShips(battleShipsSave); ShotHitTheTarget = BattleShips.FireAiShot(); BattleShips.Player1Turn = !BattleShips.Player1Turn; BattleShips.UpdateBattleShipsSave(battleShipsSave); _appDbContext.BattleShipsSaves.Update(battleShipsSave); await _appDbContext.SaveChangesAsync(); return(RedirectToPage("PlayGame", "ShowShotResult", new { id, shotHit = ShotHitTheTarget })); }