//Create Module If Exists private void CreateModuleIfExists(IEnumerable <DashboardControllerAttributeModel> dashboardControllerAttributeModel = null) { var moduleService = DependencyResolver.Current.GetService <IModuleService>(); var orderedControllerAttributes = dashboardControllerAttributeModel ?? SideBarTreeViewGenerator.GetControllerAttributesInOrder(); if (orderedControllerAttributes == null) { return; } foreach (var orderedControllerAttribute in orderedControllerAttributes) { if (orderedControllerAttribute.ChildrenActionAttributes == null) { return; } foreach (var childrenActionAttributes in orderedControllerAttribute.ChildrenActionAttributes) { var actionAttribute = moduleService.Entities.FirstOrDefault(x => x.ModuleName == childrenActionAttributes.Name); if (actionAttribute == null) { moduleService.CreateOrUpdate(new ModuleParams { Id = 0, ModuleName = childrenActionAttributes.Name }); } if (orderedControllerAttribute.ChildrenControllerAttributes != null && orderedControllerAttribute.ChildrenControllerAttributes.Any()) { CreateModuleIfExists(orderedControllerAttribute.ChildrenControllerAttributes); } } } }
public MvcHtmlString GenerateSideBarMenu() { var result = new StringBuilder(); var orderedControllerAttributes = SideBarTreeViewGenerator.GetControllerAttributesInOrder(); foreach (var orderedControllerAttribute in orderedControllerAttributes) { TagBuilder treeViewLi = null; if (orderedControllerAttribute.ParentControllerAttribute.Name == DashboardControllerType.Independent) { foreach (var childrenControllerAttribute in orderedControllerAttribute.ChildrenControllerAttributes) { treeViewLi = GenerateTreeviewLi(childrenControllerAttribute); } } else { treeViewLi = GenerateTreeviewLi(orderedControllerAttribute); } result.Append(treeViewLi); } return(MvcHtmlString.Create(result.ToString())); }