public async Task <IActionResult> EditFile(int id, GameConfigurationFile editFile) { var file = await _context.GameConfigurationFiles .Include(g => g.Configuration).ThenInclude(g => g.GameServer).ThenInclude(e => e.HostServer) .Include(g => g.Configuration).ThenInclude(g => g.Files) .FirstOrDefaultAsync(m => m.GameConfigurationFileID == id); if (file == null || file.Configuration.GameServer.HostServerID == null) { return(NotFound()); } file.Content = editFile.Content ?? string.Empty; _context.GameConfigurationFiles.Update(file); await _service.UpdateComputedProperties(file.Configuration); _context.GameServerConfigurations.Update(file.Configuration); await _context.SaveChangesAsync(); if (file.Configuration.IsActive) { using (var client = _service.GetSftpClient(file.Configuration.GameServer.HostServer)) { client.Connect(); _service.WriteAllText(client, _service.GetFileFullPath(_service.GetConfig(file.Configuration.GameServer), file.Path), file.Content ?? string.Empty); client.Disconnect(); } } return(RedirectToAction(nameof(Details), new { id = file.GameServerConfigurationID })); }