Ejemplo n.º 1
0
        private JObject SetupQueryForListing()
        {
            //Get Trial Query, inject pager stuff, call manager
            JObject query;

            //The query comes from the concrete implementation
            if (this.GetTrialQuery() != null)
            {
                query = new JObject(this.GetTrialQuery());
            }
            else
            {
                query = new JObject();
            }

            // Merge both sets of dynamic filter params.'query' overrides 'urlParams', meaning that any duplicate elements in urlParams
            // will not be included, e.g., given
            // query == { "key1":value1, "key2":["value2,value3"] }
            // and urlParms == { "key2":["value4,value5"], "key3":"value6" }
            // merged query == { "key1":value1, "key2":["value2,value3"], "key3":"value6" }
            JObject filteredQuery = TrialListingQueryHelper.MergeQueryAndURLFilters(query, HttpContext.Current.Request.QueryString);

            JObject activeTrialStatuses = new JObject();

            //Only return active statuses UNLESS the query in the listing states other statuses.
            activeTrialStatuses.Add(new JProperty("current_trial_status", new JArray(CTSConstants.ActiveTrialStatuses)));
            activeTrialStatuses.Merge(filteredQuery, new JsonMergeSettings {
                MergeArrayHandling = MergeArrayHandling.Concat
            });

            return(activeTrialStatuses);
        }
        public void MergeFilterQuery(JObject query, string filterParams, JObject expectedCriteria)
        {
            NameValueCollection coll = HttpUtility.ParseQueryString(filterParams);

            JObject filterObject = TrialListingQueryHelper.MergeQueryAndURLFilters(query, coll);

            //NOTE: Original Params (query) will come second.  So ORDER MATTERS!

            Assert.Equal(expectedCriteria, filterObject, new JTokenEqualityComparer());
        }