コード例 #1
0
        public async Task <bool> ExecuteAsync(
            UpdateSettingParameter parameter,
            string settingUrl,
            string authorizationHeaderValue)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }

            Uri uri = null;

            if (!Uri.TryCreate(settingUrl, UriKind.Absolute, out uri))
            {
                throw new ArgumentException("the uri is not correct");
            }

            var httpClient = _httpClientFactory.GetHttpClient();
            var request    = new HttpRequestMessage
            {
                Method     = HttpMethod.Put,
                RequestUri = uri,
                Content    = new StringContent(JsonConvert.SerializeObject(parameter), Encoding.UTF8, "application/json")
            };

            request.Headers.Add("Authorization", "Bearer " + authorizationHeaderValue);
            var httpResult = await httpClient.SendAsync(request).ConfigureAwait(false);

            httpResult.EnsureSuccessStatusCode();
            return(true);
        }
コード例 #2
0
        public Task <bool> Execute(UpdateSettingParameter updateSettingParameter)
        {
            if (updateSettingParameter == null)
            {
                throw new ArgumentNullException(nameof(updateSettingParameter));
            }

            if (string.IsNullOrWhiteSpace(updateSettingParameter.Key))
            {
                throw new ArgumentNullException(nameof(updateSettingParameter.Key));
            }

            return(_settingRepository.Update(new Models.Setting
            {
                Key = updateSettingParameter.Key,
                Value = updateSettingParameter.Value
            }));
        }
コード例 #3
0
 public Task <bool> UpdateSetting(UpdateSettingParameter updateSettingParameter)
 {
     return(_updateSettingAction.Execute(updateSettingParameter));
 }
コード例 #4
0
        public async Task <bool> UpdateSettingByResolving(UpdateSettingParameter parameter, string configurationUrl, string accessToken)
        {
            var url = await GetSettingUrl(configurationUrl);

            return(await UpdateSetting(parameter, url, accessToken));
        }
コード例 #5
0
 public async Task <bool> UpdateSetting(UpdateSettingParameter parameter, string settingUrl, string accessToken)
 {
     return(await _updateSettingOperation.ExecuteAsync(parameter, settingUrl, accessToken));
 }