public JsonResult GetEntities([DataSourceRequest] DataSourceRequest request, int?id) { var nodes = new List <object>(); var viewElements = new List <ViewElement>(); if (id == null) { viewElements = _viewElementService.GetRootViewElements().ToList(); } else { viewElements = _viewElementService.GetChildViewElementByParentId(id).ToList(); } //var viewElements = _viewElementService.GetAllViewElement(id).ToList(); viewElements.ForEach(viewElement => { var node = new { SortOrder = viewElement.SortOrder, id = viewElement.Id, Title = viewElement.Title, ElementType = viewElement.ElementType, Invisible = viewElement.InVisible, IsHidden = viewElement.IsHidden, UniqueName = viewElement.UniqueName, XMLViewData = viewElement.XMLViewData, hasChildren = viewElement.ChildrenViewElement.Any() }; nodes.Add(node); }); return(Json(nodes, JsonRequestBehavior.AllowGet)); }
public JsonResult Read([DataSourceRequest] DataSourceRequest request, int?id, int?selectedRole) { var nodes = new List <object>(); if (selectedRole == null) { return(Json(nodes, JsonRequestBehavior.AllowGet)); } List <ViewElement> viewElements = new List <ViewElement>(); if (User.Identity.Name.ToLower() == GeneralConstant.AdminUserName.ToLower()) { if (id == null) { viewElements = _viewElementService.GetRootViewElements().ToList(); } else { viewElements = _viewElementService.GetChildViewElementByParentId(id).ToList(); } } else { viewElements = _viewElementRoleService.GetRootViewElementsBasedOnCompany(id).ToList(); } var chekedItem = _viewElementRoleService.GetViewElementsIdByRoleId(selectedRole); viewElements.ForEach(cs => { var d = new { id = cs.Id.ToString(), Text = cs.Title, Title = cs.Title, hasChildren = (cs.ChildrenViewElement == null || cs.ChildrenViewElement.Count == 0) ? false : true, //expanded = true, @checked = chekedItem.Contains(cs.Id) }; nodes.Add(d); }); return(Json(nodes, JsonRequestBehavior.AllowGet)); }