Пример #1
0
        public ActionResult GetTreeElts(TreeViewItem node, bool?closedToo)
        {
            var user = _userProfileService.GetUser(User.Identity.Name);

            var parentId = !string.IsNullOrEmpty(node.Value) ? (int?)Convert.ToInt32(node.Value) : null;

            if (parentId == null)
            {
                // TODO: Here implement a null argument exception
                return(null);
            }
            var         thelist = _adminUnitService.GetTreeElts(parentId.Value, user.DefaultHub.Value);
            IEnumerable nodes   = from item in thelist
                                  // where item.ParentID == parentId || (parentId == null && item.ParentID == null)
                                  group item by new { item.Value, item.Name, item.LoadOnDemand }
            into itm
                        select new TreeViewItemModel
            {
                Text = itm.Key.Name + "( " + itm.Sum(l => l.Count) + " )",
                //item.Name g.Sum(b => b.QuantityInMT)
                Value        = itm.Key.Value.ToString(CultureInfo.InvariantCulture),
                LoadOnDemand = true,
                //itm.Key.LoadOnDemand,
                Enabled = true
            };

            return(new JsonResult {
                Data = nodes
            });
        }