public GetUsersAdminParam(GetUsersParam param)
 {
     foreach (var p in param.GetType().GetProperties())
     {
         GetType().GetProperty(p.Name)?.SetValue(this, p.GetValue(param));
     }
 }
        public ActionResult <PaginatedResponse <UserDto> > GetUsers([FromQuery] GetUsersParam param)
        {
            var user   = (EndUser)_userRepository.GetUser(Guid.Parse(User.Identity.Name));
            var domain = _userRepository.GetDomain(user.Domain.Id);

            return(GetUsers(new GetUsersAdminParam(param)
            {
                OrganizationCode = domain.Organization.Code
            }));
        }
示例#3
0
文件: Client.cs 项目: Gajotres100/CSP
        public GetUsersResponse GetUsers(GetUsersParam param)
        {
            var request = new RestRequest(Url.UsersUrl, Method.GET);

            request.AddUrlSegment("customer_id", param.CustomerId.ToString());

            if (param.Page.HasValue)
            {
                request.AddParameter("page", param.Page.GetValueOrDefault());
            }

            if (param.Limit.HasValue)
            {
                request.AddParameter("limit", param.Limit.GetValueOrDefault());
            }

            var url = _client.BuildUri(request);

            request = ConstructRequestHeader(request, url.PathAndQuery, String.Empty);

            var res = _client.Execute <GetUsersResult>(request);

            if (res.StatusCode != System.Net.HttpStatusCode.OK)
            {
                throw new TrendMicroApiException(res.StatusCode, res.StatusDescription, res.ErrorMessage, res.ErrorException);
            }

            return(new GetUsersResponse
            {
                PagingTotal = res.Data.paging.total,
                PagingLimit = res.Data.paging.limit,
                Page = res.Data.paging.page,
                Users = res.Data.users.Select(x => new I.User
                {
                    Id = x.user_id,
                    CustomerId = x.customer_id,
                    Status = x.status,
                    LoginName = x.login_name,
                    FirstName = x.first_name,
                    LastName = x.last_name,
                    Email = x.email,
                    TimeZone = x.time_zone,
                    Language = x.language,
                    PhoneAreaCode = x.phone.area_code,
                    PhoneNumber = x.phone.number,
                    PhoneExtension = x.phone.extension
                }).ToList()
            });
        }
示例#4
0
        public int GetUsersCount(string ApplicationCustomerID)
        {
            if (ApplicationCustomerID == null)
            {
                return(0);
            }

            var param = new GetUsersParam
            {
                CustomerId = new Guid(ApplicationCustomerID)
            };

            var res = _client.GetUsers(param);

            return(res.Users.Count());
        }