コード例 #1
0
        public ActionResult Assign(string loginId)
        {
            User user = _memberShipFactory.CreateUserDao().GetByLoginId(loginId);

            if (user == null)
            {
                throw new HttpException(404, "Cant' find the user with loginid is " + loginId);
            }
            var userGroupRoleMap   = new Dictionary <string, List <string> >();
            var rolePermissionsMap = new Dictionary <string, List <string> >();

            foreach (UserGroup ug in _memberShipFactory.CreateUserGroupDao().GetAll())
            {
                userGroupRoleMap.Add(ug.Id, new List <string>());
                foreach (Role role in ug.GetAllRoles())
                {
                    userGroupRoleMap[ug.Id].Add(role.Id);
                }
            }
            foreach (Role role in _memberShipFactory.CreateRoleDao().GetAll())
            {
                rolePermissionsMap.Add(role.Id, new List <string>());
                foreach (Permission permission in role.Permissions)
                {
                    rolePermissionsMap[role.Id].Add(permission.Id);
                }
            }
            ViewData["userGroupRoleMap"]  = userGroupRoleMap;
            ViewData["rolePermissionMap"] = rolePermissionsMap;


            return(View(user));
        }
コード例 #2
0
        public ActionResult AssignRole(string[] roles, string id)
        {
            IRoleDao  roleDao = _factory.CreateRoleDao();
            UserGroup user    =
                _factory.CreateUserGroupDao().Get(id);

            user.Roles.Clear();
            foreach (Role role in roleDao.GetRolesByName(roles))
            {
                user.Roles.Add(role);
            }
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public IEnumerable <object> Match(string name, int?page)
        {
            int          page1  = page ?? 0;
            var          user   = OrnamentContext.MemberShip.CurrentUser();
            IList <Role> result = _factory.CreateRoleDao().Find("%" + name + "%", page1, 10, user);
            var          c      = from role in result
                                  select new
            {
                id = role.Id,
                role.Name,
            };

            return(c);
        }
コード例 #4
0
 public RoleController(IMemberShipFactory factory)
 {
     _roleDao = factory.CreateRoleDao();
     _factory = factory;
 }
コード例 #5
0
 public JsonResult NotDuplicate(string name, string id)
 {
     name = Request.QueryString[0];
     return(Json(_factory.CreateRoleDao().Count(name, id) == 0, JsonRequestBehavior.AllowGet));
 }
コード例 #6
0
 public RoleController(IMemberShipFactory factory)
 {
     _roleDao = factory.CreateRoleDao();
     _factory = factory;
 }