public ActionResult Index(bool isFirstLoad = false)
        {
            var output = new List<MenuModel>();
            var account = new AccountInfo();
           
            try
            {
                var errorMessage = "";
                if (!SecurityService.ValidLdapUser(account.GetUserName(),out errorMessage))
                    return RedirectToAction("Logout");
                

                var documents = MenuService.GetTopMenu();
                foreach (var model in documents)
                {

                    var menu = new MenuModel() { LibraryName = model.LibraryName, Name = model.Name, FolderPath = model.FolderPath, ControllerName = model.ControllerName, ActionName = model.ActionName, Type = model.Type, ImageSource = model.ImageSource, ToolTip = model.ToolTip };

                    foreach (var child in model.Children)
                    {
                        menu.Children.Add(new MenuModel() { LibraryName = child.LibraryName, Name = child.Name, FolderPath = child.FolderPath, ControllerName = child.ControllerName, ActionName = child.ActionName, Type = child.Type, ToolTip = child.ToolTip });
                    }
                    output.Add(menu);
                }
            }
            catch (Exception) { return RedirectToAction("Logout"); }

            return View(output);
        }
        public ActionResult Index()
        {
            try
            {
                var documents = MenuService.GetTopMenu();
                var output = new List<MenuModel>();

                foreach (var model in documents) {

                    var menu = new MenuModel() { LibraryName = model.LibraryName, Name = model.Name, FolderPath = model.FolderPath, ControllerName = model.ControllerName, ActionName = model.ActionName, Type = model.Type,ToolTip=model.ToolTip };
                    
                    foreach (var child in model.Children) {
                        menu.Children.Add(new MenuModel() { LibraryName = child.LibraryName, Name = child.Name, FolderPath = child.FolderPath, ControllerName = child.ControllerName, ActionName = child.ActionName, Type = child.Type,ToolTip = child.ToolTip});
                    }
                    output.Add(menu);
                }

                return PartialView("Menu", output);
            }
            catch (Exception ex) { throw ex; }
        }
        //Recursive Function
        public void CreateTreeMenu(Menu menuObj, MenuModel toMenuModel)
        {
            foreach (var item in menuObj.Children)
            {
                var subMenuObj = new MenuModel
                                 {
                                     Name = item.Name,
                                     ActionName = item.ActionName,
                                     ControllerName = item.ControllerName,
                                     FolderPath = item.FolderPath,
                                     LibraryName = item.LibraryName,
                                     Class = item.Class,
                                     Type = item.Type,
                                     Id = item.Id,
                                     ParentFolderPath = item.ParentFolderPath
                                 };

                if (item.Children.Count > 0)
                   CreateTreeMenu(item, subMenuObj);

               toMenuModel.Children.Add(subMenuObj);
            }
        }