示例#1
0
        /// <summary>
        /// Gets a list of all Slack users in the current team.
        /// </summary>
        /// <param name="forceRefresh">True if the user data must be pulled from the server, false if local cache can be used.</param>
        /// <returns>User data if the user ID was found in the current team.  Null if the user was not found.</returns>
        public async Task <IEnumerable <User> > GetAllUsersAsync(bool forceRefresh = false)
        {
            // default behavior, try to pull from the local cache
            if (!forceRefresh)
            {
                return(_database.GetAllWithChildren <User>());
            }
            else
            {
                // pull a list of users from the server
                var request  = new GetAllUsersRequest();
                var response = await _restClient.RequestAsync <GetAllUsersResponse>(request);

                // TODO: should be checking response.Ok to make sure it succeeded, and handle the error if it didn't

                // cache the list of users locally
                CacheAllUsers(response.Members);

                return(response.Members);
            }
        }
示例#2
0
        /// <summary>
        /// Gets a list of all Slack users in the current team.
        /// </summary>
        /// <param name="forceRefresh">True if the user data must be pulled from the server, false if local cache can be used.</param>
        /// <returns>User data if the user ID was found in the current team.  Null if the user was not found.</returns>
        public async Task<IEnumerable<User>> GetAllUsersAsync(bool forceRefresh = false)
        {
            // default behavior, try to pull from the local cache
            if (!forceRefresh)
            {
                return _database.GetAllWithChildren<User>();
            }
            else
            {
                // pull a list of users from the server
                var request = new GetAllUsersRequest();
                var response = await _restClient.RequestAsync<GetAllUsersResponse>(request);

                // TODO: should be checking response.Ok to make sure it succeeded, and handle the error if it didn't

                // cache the list of users locally
                CacheAllUsers(response.Members);

                return response.Members;
            }
        }