public async Task <IActionResult> EditConfig(int id, [Bind("GameServerConfigurationID,ServerName,ServerPassword,ServerMission,ModsetID")] GameServerConfiguration gsc, IFormFile modset, IFormFile mission)
        {
            if (id != gsc.GameServerConfigurationID)
            {
                return(NotFound());
            }

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

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

            gsc.GameServer = existing.GameServer;

            await HandleFiles(gsc, modset, mission);

            if (ModelState.IsValid)
            {
                try
                {
                    var files = await ApplyEditConfig(existing.Files, existing, gsc);

                    existing.ServerName     = gsc.ServerName;
                    existing.ServerPassword = gsc.ServerPassword;
                    existing.ServerMission  = gsc.ServerMission;
                    existing.ModsetID       = gsc.ModsetID;

                    if (existing.GameServer.HostServerID != null)
                    {
                        foreach (var file in files)
                        {
                            _context.Update(file);
                        }

                        if (existing.IsActive)
                        {
                            using (var client = _service.GetSftpClient(existing.GameServer.HostServer))
                            {
                                client.Connect();
                                foreach (var file in files)
                                {
                                    _service.WriteAllText(client, _service.GetFileFullPath(_service.GetConfig(file.Configuration.GameServer), file.Path), file.Content);
                                }
                                client.Disconnect();
                            }
                        }
                    }

                    _context.Update(existing);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GameServerConfigurationExists(existing.GameServerConfigurationID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Details), new { id }));
            }
            return(View(existing));
        }