コード例 #1
0
        public async void Synchronize(
			Action<SynchronizationDataContainer> success = null, 
            Action<string> failure = null
        )
        {
			var request = new HttpRequest <SynchronizationDataContainer> {
                Method = HTTPMethod.GET,
                Path = pathSynchronization,
                Parameters = ParametersWithDeviceInfo(new Dictionary<string, object>()),
                Success = response => {
                    if ( success != null )
                    {
                        success(response.MappedResponse);
                    }
                },
                Failure = response => {

                    if ( failure != null )
                    {
                        failure(response.Error.LocalizedMessage);
                    }
                }
            };

            await request.Perform();
        }
コード例 #2
0
        public async void Rate(
            Argument argument,
            float rating,
            Action<Argument> success = null, 
            Action<string> failure = null
        )
        {
            var parameters = new Dictionary<string, object> {
                {paramRateValue,rating}
            };

            var request = new HttpRequest <ResponseJsonArgumentRating> {
                Method = HTTPMethod.POST,
                Path = string.Format(pathRate,argument.Id),
                Parameters = ParametersWithDeviceInfo(parameters),
                Success = response => {
					SynchronizationManager.Instance.CancelWriteToDatabaseIfSynchronizationInProgress();
                    DatabaseHelper.Replace<Argument>(response.MappedResponse.Argument);
                    DatabaseHelper.Replace<User>(response.MappedResponse.User);

                    if ( success != null )
                    {
                        success(response.MappedResponse.Argument);
                    }
                },
                Failure = response => {

                    if ( failure != null )
                    {
                        failure(response.Error.LocalizedMessage);
                    }
                }
            };
            
            await request.Perform();
        }
コード例 #3
0
        public async void CreateOrUpdate(
            Argument argument,
            Action<Argument> success = null, 
            Action<string> failure = null
        )
        {   
            bool update = argument.Id > 0;
            
            var parameters = new Dictionary<string, object> {
                {paramProductGroupId,argument.ProductGroupId},
                {paramFeature,argument.Feature},
                {paramBenefit,argument.Benefit}
            };
            
            var method = HTTPMethod.POST;
            var path = string.Format(pathArgumentCreate);
            if (update)
            {
                parameters.Add(paramArgumentId, argument.Id);
                method = HTTPMethod.PUT;
                path = string.Format(pathArgumentUpdate, argument.Id);
            }
            
            var request = new HttpRequest <ResponseJsonArgument> {
                Method = method,
                Path = path,
                Parameters = ParametersWithDeviceInfo(parameters),
                Success = response => {
					SynchronizationManager.Instance.CancelWriteToDatabaseIfSynchronizationInProgress();
                    DatabaseHelper.Replace<Argument>(response.MappedResponse.Argument);
                    DatabaseHelper.Replace<User>(response.MappedResponse.User);

                    if ( success != null )
                    {
                        success(response.MappedResponse.Argument);
                    }
                },
                Failure = response => {

                    if ( failure != null )
                    {
                        failure(response.Error.LocalizedMessage);
                    }
                }
            };

            await request.Perform();
        }