public async Task <bool> ImportPanelJson(string json, int x, int y, string ownerPanelId)
        {
            return(await Task.Run(() =>
            {
                if (engine == null)
                {
                    return false;
                }

                try
                {
                    List <Nodes.Node> nodes;
                    List <Nodes.Link> links;
                    NodesEngineSerializer.DeserializePanel(json, out nodes, out links);

                    foreach (var node in nodes)
                    {
                        if (node.GetNodeOptions().ProtectedAccess)
                        {
                            if (!User.HasClaim(с => с.Type == UserClaims.EditorProtectedAccess))
                            {
                                engine.LogEngineError(
                                    $"Can`t import panel. Panel contains the nodes with protected access. No permissions for this operation.");
                                return true;
                            }
                        }
                    }


                    //set position to panel
                    nodes[0].Position = new Position(x, y);
                    nodes[0].PanelId = ownerPanelId;

                    engine.GenerateNewIds(ref nodes, ref links);


                    int adddedNodes = engine.AddNodes(nodes);
                    int adddedLinks = engine.AddLinks(links);

                    return (adddedNodes == nodes.Count && adddedLinks == links.Count);
                }
                catch
                {
                    return false;
                }
            }));
        }
        public async Task <string> SerializePanel(string id)
        {
            return(await Task.Run(() =>
            {
                if (engine == null)
                {
                    return null;
                }

                PanelNode node = engine.GetPanelNode(id);
                if (node == null)
                {
                    return null;
                }

                return NodesEngineSerializer.SerializePanel(id, engine);
            }));
        }
        public async Task <IActionResult> SerializePanelToFile(string id)
        {
            return(await Task.Run(() =>
            {
                if (engine == null)
                {
                    return null;
                }

                PanelNode node = engine.GetPanelNode(id);
                if (node == null)
                {
                    return null;
                }

                string json = NodesEngineSerializer.SerializePanel(id, engine);

                return File(Encoding.UTF8.GetBytes(json), "text/plain", node.Settings["Name"].Value + ".json");
            }));
        }