コード例 #1
0
        public IActionResult Index(UserAuthorizationPolicyFilterModel filter)
        {
            var filterRequest = new UserAuthorizationPolicyFilter
            {
                Page     = filter.Page,
                PageSize = _pagerOptions.PageSize,
                Keyword  = filter.Search
            };
            var authorizationPolicy = _userAuthorizationPolicyService.GetAuthoricationPolicyUsers(filter.Id, filterRequest);

            var users = authorizationPolicy.Collections.Select(x => new UserModel
            {
                DisplayName = x.DisplayName,
                Firstname   = x.Firstname,
                Lastname    = x.Lastname,
                Id          = x.Id
            });
            var authorizationUsersPage = new AuthorizationPolicyUsersModel(users)
            {
                Description = authorizationPolicy.Description,
                Id          = authorizationPolicy.Id,
                Name        = authorizationPolicy.Name,
                TotalPage   = authorizationPolicy.TotalPage,
                TotalResult = authorizationPolicy.TotalResult,
                Filter      = filter
            };

            if (_httpHelper.IsAjaxRequest(Request))
            {
                return(PartialView("_UserAuthorizationPolicyTable", authorizationUsersPage));
            }

            return(View(authorizationUsersPage));
        }
コード例 #2
0
        public AuthorizationPolicyUsersPageList GetAuthoricationPolicyUsers(long id, UserAuthorizationPolicyFilter filter)
        {
            var search = filter.Keyword != null?filter.Keyword.ToLower() : "";

            var query = from userAuthorization in _userAuthorizationPolicyRepository.Get(x => x.AuthorizationPolicyId == id)
                        join user in _userRepository.Table
                        on userAuthorization.UserId equals user.Id
                        where string.IsNullOrEmpty(search) ||
                        user.Lastname.ToLower().Contains(search) ||
                        user.Firstname.ToLower().Contains(search) ||
                        (user.Lastname + " " + user.Firstname).ToLower().Contains(search)
                        select new UserResult()
            {
                DisplayName = user.DisplayName,
                Firstname   = user.Firstname,
                Lastname    = user.Lastname,
                Id          = user.Id
            };

            var filteredNumber = query.Select(x => x.Id).Count();
            var roles          = query.Skip(filter.PageSize * (filter.Page - 1))
                                 .Take(filter.PageSize).ToList();

            var authorizationPolicy = _authorizationPolicyRepository.Get(x => x.Id == id)
                                      .Select(x => new AuthorizationPolicyUsersPageList
            {
                Id          = x.Id,
                Name        = x.Name,
                Description = x.Description
            })
                                      .FirstOrDefault();

            authorizationPolicy.Collections = roles;
            authorizationPolicy.TotalResult = filteredNumber;
            authorizationPolicy.TotalPage   = (int)Math.Ceiling((double)filteredNumber / filter.PageSize);

            return(authorizationPolicy);
        }
コード例 #3
0
 public AuthorizationPolicyUsersPageList GetAuthoricationPolicyUsers(long id, UserAuthorizationPolicyFilter filter)
 {
     return(_userAuthorizationPolicyRepository.GetAuthoricationPolicyUsers(id, filter));
 }