// GET: AdminGameServerConfigurations/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var gameServerConfiguration = await _context.GameServerConfigurations
                                          .Include(g => g.GameServer).ThenInclude(g => g.HostServer)
                                          .Include(g => g.Modset)
                                          .Include(g => g.Files)
                                          .FirstOrDefaultAsync(m => m.GameServerConfigurationID == id);

            if (gameServerConfiguration == null)
            {
                return(NotFound());
            }

            if (gameServerConfiguration.IsActive && gameServerConfiguration.GameServer.HostServerID != null)
            {
                var gameConfig = _service.GetConfig(gameServerConfiguration.GameServer);
                using (var client = _service.GetSftpClient(gameConfig.Server))
                {
                    client.Connect();
                    await _service.SyncConfig(client, gameConfig, gameServerConfiguration);

                    client.Disconnect();
                }
            }

            return(View(gameServerConfiguration));
        }
        public async Task <IActionResult> Details(int id)
        {
            var gameServer = await _context.GameServers
                             .Include(g => g.HostServer)
                             .Where(g => g.GameServerID == id)
                             .FirstOrDefaultAsync();

            if (gameServer == null)
            {
                return(BadRequest());
            }

            var currentConfig = await GetActiveConfiguration(gameServer);

            var vm = new ServerInfosViewModel();

            vm.GameServer = gameServer;
            vm.GameServer.Configurations = await _context.GameServerConfigurations
                                           .Include(c => c.Modset)
                                           .Where(c => c.GameServerID == gameServer.GameServerID).ToListAsync();

            vm.GameServer.SyncFiles = await _context.GameServerSyncedFiles
                                      .Include(c => c.GameServer)
                                      .Where(c => c.GameServerID == gameServer.GameServerID).ToListAsync();

            vm.CurrentConfig = currentConfig;

            if (gameServer.HostServerID != null)
            {
                var gameConfig = _service.GetConfig(gameServer);
                using (var client = _service.GetSftpClient(gameConfig.Server))
                {
                    client.Connect();
                    if (!string.IsNullOrEmpty(gameConfig.MissionDirectory) && gameServer.Type == GameServerType.Arma3)
                    {
                        vm.MissionFiles = client.ListDirectory(gameConfig.MissionDirectory).Where(f => f.IsRegularFile).Select(f => Path.GetFileName(f.FullName)).Where(f => f.EndsWith(".pbo", StringComparison.OrdinalIgnoreCase)).ToList();
                        vm.MissionFiles.Sort();
                    }
                    await _service.SyncConfig(client, gameConfig, currentConfig);

                    client.Disconnect();
                }
                vm.Game        = gameConfig;
                vm.Infos       = _service.GetGameInfos(gameServer, _service.GetRunningProcesses(gameConfig.Server));
                vm.ConfigFiles = gameConfig.ConfigFiles.Select((f, i) => new ConfigFileInfos()
                {
                    Index = i,
                    Name  = Path.GetFileName(f)
                }).ToList();
            }
            return(View(vm));
        }