示例#1
0
        public ActionResult UserList(DataSourceRequest command, UserListModel model,
            [ModelBinder(typeof(CommaSeparatedModelBinder))] int[] searchUserRoleIds) {
            //we use own own binder for searchCustomerRoleIds property 
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageUsers))
                return AccessDeniedView();

            var customers = _userService.GetAllUsers(
                UserRoleIds: searchUserRoleIds,
                departmentId: model.SearchDepartmentId,
                email: model.SearchEmail,
                username: model.SearchUsername,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize);
            var gridModel = new DataSourceResult {
                Data = customers.Select(PrepareUserModelForList),
                Total = customers.TotalCount
            };

            return Json(gridModel);
        }
示例#2
0
        public ActionResult List() {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageUsers))
                return AccessDeniedView();

            //load registered users by default
            var defaultRoleIds = new[] { _userService.GetUserRoleBySystemName(SystemUserRoleNames.Registered).Id };
            var model = new UserListModel {
                AvailableUserRoles = _userService.GetAllUserRoles(true).Select(cr => cr.ToModel()).ToList(),
                SearchUserRoleIds = defaultRoleIds
            };

            foreach (var at in _departmentService.GetAll()) {
                model.AvailableDepartments.Add(new SelectListItem {
                    Value = at.Id.ToString(),
                    Text = at.GetFormattedBreadCrumb(_departmentService)
                });
            }

            return View(model);
        }