Ejemplo n.º 1
0
        public IEnumerable <object> Match(string name, int?page)
        {
            User currentUser = OrnamentContext.MemberShip.CurrentUser();

            if (OrnamentContext.MemberShip.HasRight(ResourceSetting.Org, OrgOperator.Read))
            {
                IOrgDao           orgDao    = _factory.CreateOrgDao();
                int               pageIndex = page ?? 0;
                IEnumerable <Org> result    = currentUser.Org == null
                    ? orgDao.Find(name, pageIndex, 10)
                    : orgDao.Find(currentUser.Org, name, pageIndex, 10);

                var c = from org in result
                        select new
                {
                    id = org.Id,
                    org.Name,
                };
                return(c);
            }
            return(new List <object>
            {
                new
                {
                    id = "",
                    Name = "没有权限访问组织"
                }
            });
        }
Ejemplo n.º 2
0
        public ActionResult Index(string id)
        {
            if (id == null)
            {
                User user              = OrnamentContext.MemberShip.CurrentUser();
                var  isOrgUser         = user.LoginId != MemberShip.User.AdminLoginId && user.Org != null;
                IEnumerable <Org> orgs = isOrgUser
                    ? _factory.CreateOrgDao().GetSubOrgs(OrnamentContext.MemberShip.CurrentUser().Org)
                    : _factory.CreateOrgDao().GetRootOrgs();
                ViewData["Orgs"] = orgs;
                if (isOrgUser)
                {
                    return(View(user.Org));
                }

                return(View((Org)null));
            }
            Org org = _factory.CreateOrgDao().Get(id);

            ViewData["Orgs"] = org.Childs;
            return(View(org));
        }