Exemplo n.º 1
0
        public bool PopulateSubscriptions()
        {
            bool response = false;

            if (Subscriptions.Length == 0 && !string.IsNullOrEmpty(Config.AzureSubscriptionId))
            {
                response = _httpClient.SendRequest(_getSubscriptionRestUri, BearerToken
                                                   .Replace("{subscriptionId}", Config.AzureSubscriptionId));

                Subscriptions = new SubscriptionRecordResult[1]
                {
                    JsonConvert.DeserializeObject <SubscriptionRecordResult>(_httpClient.ResponseStreamString)
                };
            }
            else
            {
                response      = _httpClient.SendRequest(_listSubscriptionsRestUri, BearerToken);
                Subscriptions = (JsonConvert.DeserializeObject <SubscriptionRecordResults>(_httpClient.ResponseStreamString)).value
                                .Where(x => x.state.ToLower() == "enabled").ToArray();
            }

            return(response);
        }