/// <summary> /// The update survey sample fitler and its value. /// </summary> /// <param name="surveyId"> /// The survey id. /// </param> /// <param name="sampleQueryElementId"> /// The sample query element id. /// </param> /// <param name="variableId"> /// The variable id. /// </param> /// <param name="operation"> /// The operation. /// </param> /// <param name="Operator"> /// The operator. /// </param> /// <param name="value"> /// The value. /// </param> /// <returns> /// The <see cref="SampleRoot"/>. /// </returns> public SampleRoot UpdateFitler( long surveyId, long sampleQueryElementId, long variableId, SampleOperation operation, SampleOperator Operator, string value) { if (surveyId < 1 || sampleQueryElementId < 1 || variableId < 1 || string.IsNullOrEmpty(value)) { return(_result.ErrorToObject(new SampleRoot(), "Invalid parameter(s)")); } var requestArg = JsonConvert.SerializeObject( new { SurveyId = surveyId, SampleQueryElementId = sampleQueryElementId, VariableId = variableId, AndOr = operation.ToString(), OperatorId = (short)Operator, Value = value }); requestArg = JsonConvert.SerializeObject(new { Data = requestArg }); Task <Result> x = RequestHandler.SendRequestAsync( string.Empty, "api/UserSample/UpdateSampleFilter", HttpMethod.Put, RouteStyle.Rpc, requestArg); x.Wait(); return(x.Result.JsonToObject(new SampleRoot(), "Filters")); }
/// <summary> /// The add sample filters. /// </summary> /// <param name="surveyId"> /// The survey id. /// </param> /// <param name="sampleId"> /// The sample id. /// </param> /// <param name="operation"> /// The operation. /// </param> /// <param name="Operator"> /// The operator. /// </param> /// <param name="variableId"> /// The variable id. /// </param> /// <param name="value"> /// The value. /// </param> /// <returns> /// The <see cref="SampleRoot"/>. /// </returns> public SampleRoot AddSampleFilters( long surveyId, long sampleId, SampleOperation operation, SampleOperator Operator, int variableId, string value) { // Problem in adding filter.Need to resolve. if (surveyId < 1 || sampleId < 1 || variableId < 1 || string.IsNullOrEmpty(value)) { return(_result.ErrorToObject(new SampleRoot(), "Invalid parameter(s)")); } var fields = JsonConvert.SerializeObject( new { AndOr = operation.ToString(), FieldName = "FirstName", variableID = variableId, Operator = Operator, Value = value }); var requestArg = JsonConvert.SerializeObject( new { SampleID = sampleId, SurveyID = surveyId, Fields = "[" + fields + "]" }); requestArg = JsonConvert.SerializeObject(new { Data = requestArg }); Task <Result> x = RequestHandler.SendRequestAsync( string.Empty, "api/UserSample/AddFilter", HttpMethod.Post, RouteStyle.Rpc, requestArg); x.Wait(); return(x.Result.JsonToObject(new SampleRoot())); }