コード例 #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 Index(Pagination pagination)
        {
            IUserGroupDao     dao = _factory.CreateUserGroupDao();
            int               total;
            IList <UserGroup> result = dao.FindAll(pagination.CurrentPage, pagination.PageSize, out total);

            pagination.TotalRows = total;
            ViewData["Nav"]      = pagination;
            return(View(result));
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">Product's Id</param>
        /// <returns></returns>
        public ActionResult Create(int id)
        {
            var performers = new List <IPerformer>();

            performers.AddRange(_memberShipFactory.CreateUserDao().GetAll());
            performers.AddRange(_memberShipFactory.CreateUserGroupDao().GetAll());

            ViewData["performers"] = performers;

            var v = new ProjectModel
            {
                Product = _dao.ProductDao.Get(id)
            };

            return(View(v));
        }
コード例 #4
0
        // GET api/usersapi
        public IEnumerable <object> Get(string name, int?page)
        {
            int page1 = page ?? 0;
            IEnumerable <UserGroup> result = _factory.CreateUserGroupDao().Find(name, page1, 10);

            var c = from user in result
                    select new
            {
                id = user.Id,
                user.Name,
            };

            return(c);
        }