internal static Attempt <MenuItemCollection> TryGetMenuFromLegacyTreeRootNode(this ApplicationTree appTree, FormDataCollection formCollection, UrlHelper urlHelper)
        {
            var rootAttempt = appTree.TryGetRootXmlNodeFromLegacyTree(formCollection, urlHelper);

            if (rootAttempt.Success == false)
            {
                return(Attempt <MenuItemCollection> .Fail(rootAttempt.Exception));
            }

            var currentSection = formCollection.GetRequiredString("section");

            var result = LegacyTreeDataConverter.ConvertFromLegacyMenu(rootAttempt.Result, currentSection);

            return(Attempt.Succeed(result));
        }
        internal static Attempt <MenuItemCollection> TryGetMenuFromLegacyTreeNode(this ApplicationTree appTree, string parentId, string nodeId, FormDataCollection formCollection, UrlHelper urlHelper)
        {
            var xTreeAttempt = appTree.TryGetXmlTree(parentId, formCollection);

            if (xTreeAttempt.Success == false)
            {
                return(Attempt <MenuItemCollection> .Fail(xTreeAttempt.Exception));
            }

            var currentSection = formCollection.GetRequiredString("section");

            var result = LegacyTreeDataConverter.ConvertFromLegacyMenu(nodeId, xTreeAttempt.Result, currentSection);

            if (result == null)
            {
                return(Attempt <MenuItemCollection> .Fail(new ApplicationException("Could not find the node with id " + nodeId + " in the collection of nodes contained with parent id " + parentId)));
            }
            return(Attempt.Succeed(result));
        }