Esempio n. 1
0
        public static Task <IEnumerable <Group> > GetAllGroupsAsync(this IUserManager userManager, Action <GetAllGroupsOptions> configureOptions)
        {
            var options = new GetAllGroupsOptions();

            configureOptions(options);

            return(userManager.GetAllGroupsAsync(options));
        }
Esempio n. 2
0
        public async Task <IEnumerable <Group> > GetAllGroupsAsync(GetAllGroupsOptions options)
        {
            var uri = GetGroupsUri();

            Logger.LogInformation($"Attempting to get all groups - {uri}");

            try
            {
                // get group
                var result = await _client.GetAsync(uri, options.CancellationToken).ConfigureAwait(false);

                result.EnsureSuccessStatusCode();

                // get groups from results
                var json = JArray.Parse(await result.Content.ReadAsStringAsync().ConfigureAwait(false));
                return(json.Select(Group.FromJson));
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Error trying to get all groups - {uri}");
                throw;
            }
        }