/// <summary> /// Helper method to create a root model for a tree /// </summary> /// <returns></returns> protected virtual ActionResult <TreeNode?> CreateRootNode(FormCollection queryStrings) { var rootNodeAsString = Constants.System.RootString; queryStrings.TryGetValue(TreeQueryStringParameters.Application, out StringValues currApp); var node = new TreeNode( rootNodeAsString, null, //this is a root node, there is no parent Url.GetTreeUrl(_apiControllers, GetType(), rootNodeAsString, queryStrings), Url.GetMenuUrl(_apiControllers, GetType(), rootNodeAsString, queryStrings)) { HasChildren = true, RoutePath = currApp, Name = RootNodeDisplayName }; return(node); }
/// <summary> /// If the request is for a dialog mode tree /// </summary> /// <param name="queryStrings"></param> /// <returns></returns> protected bool IsDialog(FormCollection queryStrings) { queryStrings.TryGetValue(TreeQueryStringParameters.Use, out StringValues use); return(use == "dialog"); }
/// <summary> /// Returns the object based in the collection based on it's key. This does this with a conversion so if it doesn't convert a null object is returned. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="items"></param> /// <param name="key"></param> /// <returns></returns> public static T GetValue <T>(this FormCollection items, string key) { if (items.TryGetValue(key, out var val) == false || string.IsNullOrEmpty(val)) { return(default);