Example #1
0
        /// <summary>
        /// 保存用户设置
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public bool SaveUserSettingByToken(string token, MySettingInfo mySetting)
        {
            bool result = false;

            try
            {
                string apiName = "setting";
                UpdateSettingRequest settingRequest = new UpdateSettingRequest();
                settingRequest.notSelectedType = new List <string>();
                settingRequest.imageActive     = mySetting.IsCheckPicInDucument;
                settingRequest.customActive    = mySetting.IsUseCustumCi;
                foreach (var item in mySetting.CategoryInfos)
                {
                    if (!item.CheckedState)
                    {
                        settingRequest.notSelectedType.Add(item.Code);
                    }
                }
                string         json       = JsonConvert.SerializeObject(settingRequest);
                string         resultStr  = HttpHelper.HttpUrlSend(apiName, "PATCH", json, token);
                CommonResponse resultInfo = JsonConvert.DeserializeObject <CommonResponse>(resultStr);
                if (resultInfo != null && resultInfo.state)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                WPFClientCheckWordUtil.Log.TextLog.SaveError(ex.Message);
            }
            return(result);
        }
Example #2
0
        public async stt::Task UpdateSettingRequestObjectAsync()
        {
            moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient> mockGrpcClient = new moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient>(moq::MockBehavior.Strict);
            UpdateSettingRequest request = new UpdateSettingRequest
            {
                Setting = new Setting(),
            };
            Setting expectedResponse = new Setting
            {
                SettingName    = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
                Metadata       = new SettingMetadata(),
                LocalValue     = new Value(),
                EffectiveValue = new Value(),
                Etag           = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.UpdateSettingAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Setting>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ResourceSettingsServiceClient client = new ResourceSettingsServiceClientImpl(mockGrpcClient.Object, null);
            Setting responseCallSettings         = await client.UpdateSettingAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Setting responseCancellationToken = await client.UpdateSettingAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 public static UpdateSettingParameter ToParameter(this UpdateSettingRequest request)
 {
     return(new UpdateSettingParameter
     {
         Key = request.Key,
         Value = request.Value
     });
 }
        public async Task <ActionResult> Put([FromBody] UpdateSettingRequest updateSettingRequest)
        {
            if (updateSettingRequest == null)
            {
                throw new ArgumentNullException(nameof(updateSettingRequest));
            }

            if (!await _settingActions.UpdateSetting(updateSettingRequest.ToParameter()))
            {
                return(new NotFoundResult());
            }

            return(new NoContentResult());
        }
Example #5
0
 /// <summary>Snippet for UpdateSetting</summary>
 public void UpdateSettingRequestObject()
 {
     // Snippet: UpdateSetting(UpdateSettingRequest, CallSettings)
     // Create client
     ResourceSettingsServiceClient resourceSettingsServiceClient = ResourceSettingsServiceClient.Create();
     // Initialize request argument(s)
     UpdateSettingRequest request = new UpdateSettingRequest
     {
         Setting = new Setting(),
     };
     // Make the request
     Setting response = resourceSettingsServiceClient.UpdateSetting(request);
     // End snippet
 }
Example #6
0
        /// <summary>Snippet for UpdateSettingAsync</summary>
        public async Task UpdateSettingRequestObjectAsync()
        {
            // Snippet: UpdateSettingAsync(UpdateSettingRequest, CallSettings)
            // Additional: UpdateSettingAsync(UpdateSettingRequest, CancellationToken)
            // Create client
            ResourceSettingsServiceClient resourceSettingsServiceClient = await ResourceSettingsServiceClient.CreateAsync();

            // Initialize request argument(s)
            UpdateSettingRequest request = new UpdateSettingRequest
            {
                Setting = new Setting(),
            };
            // Make the request
            Setting response = await resourceSettingsServiceClient.UpdateSettingAsync(request);

            // End snippet
        }
Example #7
0
        public async Task <Response <SettingResponse> > Update(UpdateSettingRequest request)
        {
            var setting = await _uow.Settings.GetSettings();

            if (setting == null)
            {
                return(new Response <SettingResponse>(ResponseStatus.NotFound, null, ResponseMessagesConstans.NotFound));
            }

            setting.MaxServicesInDay    = request.MaxServicesInDay;
            setting.MaxAvailabilityDays = request.MaxAvailabilityDays;

            await _uow.Settings.ReplaceAsync(setting.Id, setting);

            var response = _mapService.MapSettings(setting);

            return(new Response <SettingResponse>(ResponseStatus.Ok, response));
        }
Example #8
0
        public ActionResult UpdateSetting([FromBody] UpdateSettingRequest request)
        {
            var setting = _dbContext.Setting.FirstOrDefault(s => s.Code == request.Code);

            if (setting == null)
            {
                setting      = new Setting();
                setting.Code = request.Code;
                _dbContext.Add(setting);
            }
            else
            {
                _dbContext.Update(setting);
            }

            setting.Value = request.Value;

            _dbContext.SaveChanges();

            return(Ok());
        }
Example #9
0
        public void UpdateSettingRequestObject()
        {
            moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient> mockGrpcClient = new moq::Mock <ResourceSettingsService.ResourceSettingsServiceClient>(moq::MockBehavior.Strict);
            UpdateSettingRequest request = new UpdateSettingRequest
            {
                Setting = new Setting(),
            };
            Setting expectedResponse = new Setting
            {
                SettingName    = SettingName.FromProjectNumberSettingName("[PROJECT_NUMBER]", "[SETTING_NAME]"),
                Metadata       = new SettingMetadata(),
                LocalValue     = new Value(),
                EffectiveValue = new Value(),
                Etag           = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.UpdateSetting(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ResourceSettingsServiceClient client = new ResourceSettingsServiceClientImpl(mockGrpcClient.Object, null);
            Setting response = client.UpdateSetting(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #10
0
 /// <summary>
 /// Updates a setting.
 ///
 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
 /// setting does not exist.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if
 /// the setting is flagged as read only.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
 /// supplied in the request does not match the persisted etag of the setting
 /// value.
 ///
 /// On success, the response will contain only `name`, `local_value` and
 /// `etag`.  The `metadata` and `effective_value` cannot be updated through
 /// this API.
 ///
 /// Note: the supplied setting will perform a full overwrite of the
 /// `local_value` field.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public override Setting UpdateSetting(UpdateSettingRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_UpdateSettingRequest(ref request, ref callSettings);
     return(_callUpdateSetting.Sync(request, callSettings));
 }
Example #11
0
        public async Task <IHttpActionResult> Update([FromBody] UpdateSettingRequest request)
        {
            var response = await _settingService.Update(request);

            return(new CreateResult(response));
        }
Example #12
0
 /// <summary>
 /// Updates a setting.
 ///
 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
 /// setting does not exist.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if
 /// the setting is flagged as read only.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
 /// supplied in the request does not match the persisted etag of the setting
 /// value.
 ///
 /// On success, the response will contain only `name`, `local_value` and
 /// `etag`.  The `metadata` and `effective_value` cannot be updated through
 /// this API.
 ///
 /// Note: the supplied setting will perform a full overwrite of the
 /// `local_value` field.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual Setting UpdateSetting(UpdateSettingRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
Example #13
0
 /// <summary>
 /// Updates a setting.
 ///
 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
 /// setting does not exist.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if
 /// the setting is flagged as read only.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
 /// supplied in the request does not match the persisted etag of the setting
 /// value.
 ///
 /// On success, the response will contain only `name`, `local_value` and
 /// `etag`.  The `metadata` and `effective_value` cannot be updated through
 /// this API.
 ///
 /// Note: the supplied setting will perform a full overwrite of the
 /// `local_value` field.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Setting> UpdateSettingAsync(UpdateSettingRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
Example #14
0
 /// <summary>
 /// Updates a setting.
 ///
 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
 /// setting does not exist.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if
 /// the setting is flagged as read only.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
 /// supplied in the request does not match the persisted etag of the setting
 /// value.
 ///
 /// On success, the response will contain only `name`, `local_value` and
 /// `etag`.  The `metadata` and `effective_value` cannot be updated through
 /// this API.
 ///
 /// Note: the supplied setting will perform a full overwrite of the
 /// `local_value` field.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Setting> UpdateSettingAsync(UpdateSettingRequest request, st::CancellationToken cancellationToken) =>
 UpdateSettingAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
        /// <summary>
        /// Update a setting
        /// </summary>
        /// <exception cref="Cloudmersive.APIClient.NETCore.ConfigurationAPI.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request">Request to perform the operation on</param>
        /// <returns>Task of ApiResponse (UpdateSettingResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <UpdateSettingResponse> > SettingsUpdateSettingAsyncWithHttpInfo(UpdateSettingRequest request)
        {
            // verify the required parameter 'request' is set
            if (request == null)
            {
                throw new ApiException(400, "Missing required parameter 'request' when calling SettingsApi->SettingsUpdateSetting");
            }

            var    localVarPath         = "./config/settings/update";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json",
                "text/json",
                "application/xml",
                "text/xml",
                "application/x-www-form-urlencoded"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json",
                "text/json",
                "application/xml",
                "text/xml"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (request != null && request.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(request); // http body (model) parameter
            }
            else
            {
                localVarPostBody = request; // byte array
            }

            // authentication (Apikey) required
            if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("Apikey")))
            {
                localVarHeaderParams["Apikey"] = this.Configuration.GetApiKeyWithPrefix("Apikey");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("SettingsUpdateSetting", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <UpdateSettingResponse>(localVarStatusCode,
                                                           localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()),
                                                           (UpdateSettingResponse)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(UpdateSettingResponse))));
        }
        /// <summary>
        /// Update a setting
        /// </summary>
        /// <exception cref="Cloudmersive.APIClient.NETCore.ConfigurationAPI.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request">Request to perform the operation on</param>
        /// <returns>Task of UpdateSettingResponse</returns>
        public async System.Threading.Tasks.Task <UpdateSettingResponse> SettingsUpdateSettingAsync(UpdateSettingRequest request)
        {
            ApiResponse <UpdateSettingResponse> localVarResponse = await SettingsUpdateSettingAsyncWithHttpInfo(request);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// Update a setting
        /// </summary>
        /// <exception cref="Cloudmersive.APIClient.NETCore.ConfigurationAPI.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request">Request to perform the operation on</param>
        /// <returns>UpdateSettingResponse</returns>
        public UpdateSettingResponse SettingsUpdateSetting(UpdateSettingRequest request)
        {
            ApiResponse <UpdateSettingResponse> localVarResponse = SettingsUpdateSettingWithHttpInfo(request);

            return(localVarResponse.Data);
        }
Example #18
0
 /// <summary>
 /// Updates a setting.
 ///
 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
 /// setting does not exist.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if
 /// the setting is flagged as read only.
 /// Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
 /// supplied in the request does not match the persisted etag of the setting
 /// value.
 ///
 /// On success, the response will contain only `name`, `local_value` and
 /// `etag`.  The `metadata` and `effective_value` cannot be updated through
 /// this API.
 ///
 /// Note: the supplied setting will perform a full overwrite of the
 /// `local_value` field.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public override stt::Task <Setting> UpdateSettingAsync(UpdateSettingRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_UpdateSettingRequest(ref request, ref callSettings);
     return(_callUpdateSetting.Async(request, callSettings));
 }
Example #19
0
 partial void Modify_UpdateSettingRequest(ref UpdateSettingRequest request, ref gaxgrpc::CallSettings settings);