コード例 #1
0
        public async Task <IActionResult> GetAllUsersAsync([FromQuery] Client.UserSearchInfo clientSearchInfo,
                                                           CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var users = await Task.Run(() => userManager.Users, cancellationToken);

            var modelSearchInfo =
                Converter.UserSearchInfoConverter.Convert(clientSearchInfo ?? new Client.UserSearchInfo());

            if (modelSearchInfo.Offset != null)
            {
                users = users.Skip(modelSearchInfo.Offset.Value);
            }

            if (modelSearchInfo.Limit != null)
            {
                users = users.Take(modelSearchInfo.Limit.Value);
            }

            users = users.OrderByDescending(item => item.LastUpdateAt);

            var clientUsers = users.Select(user => Converter.UserConverter.Convert(user));

            return(Ok(clientUsers));
        }
コード例 #2
0
        public static Model.UserSearchInfo Convert(Client.UserSearchInfo clientSearchInfo)
        {
            if (clientSearchInfo == null)
            {
                throw new ArgumentNullException(nameof(clientSearchInfo));
            }

            var modelSearchInfo = new Model.UserSearchInfo
            {
                Offset = clientSearchInfo.Offset,
                Limit  = clientSearchInfo.Limit
            };

            return(modelSearchInfo);
        }