public ActionResult Index(string filter = null)
        {
            var list = new List<GroupViewModel>();
            using (var tx = this.session.BeginTransaction())
            {
                foreach (var result in this.groupRepository.Query(this.groupSvc.DefaultTenant, filter))
                {
                    var item = this.groupSvc.Get(result.ID);

                    var kids = new List<GroupViewModel>();
                    foreach (var child in item.Children)
                    {
                        var childGrp = this.groupSvc.Get(child.ChildGroupID);
                        kids.Add(new GroupViewModel { ID = child.ChildGroupID, Name = childGrp.Name });
                    }

                    var descendants = this.groupSvc.GetDescendants(item).Select(x => x.Name).ToArray();
                    var gvm = new GroupViewModel
                                  {
                                      ID = item.ID,
                                      Name = item.Name,
                                      Children = kids,
                                      Descendants = descendants
                                  };
                    list.Add(gvm);
                }

                tx.Commit();
            }

            var vm = new GroupIndexViewModel { Groups = list };
            return this.View("Index", vm);
        }
Ejemplo n.º 2
0
        public ActionResult Index(string filter = null)
        {
            var list = new List <GroupViewModel>();

            using (var tx = this.session.BeginTransaction())
            {
                foreach (var result in this.groupRepository.Query(this.groupSvc.DefaultTenant, filter))
                {
                    var item = this.groupSvc.Get(result.ID);

                    var kids = new List <GroupViewModel>();
                    foreach (var child in item.Children)
                    {
                        var childGrp = this.groupSvc.Get(child.ChildGroupID);
                        kids.Add(new GroupViewModel {
                            ID = child.ChildGroupID, Name = childGrp.Name
                        });
                    }

                    var descendants = this.groupSvc.GetDescendants(item).Select(x => x.Name).ToArray();
                    var gvm         = new GroupViewModel
                    {
                        ID          = item.ID,
                        Name        = item.Name,
                        Children    = kids,
                        Descendants = descendants
                    };
                    list.Add(gvm);
                }

                tx.Commit();
            }

            var vm = new GroupIndexViewModel {
                Groups = list
            };

            return(this.View("Index", vm));
        }