Пример #1
0
        public virtual async Task <IRockResponse <List <T> > > SearchHttp(BaseQO qo)
        {
            using (var http = CreateClient())
            {
                var searchUrl = SearchUrl + "?" + qo.ToQueryString();
                var response  = await http.GetAsync(searchUrl);

                var rockresponse = new RockResponse <List <T> >();

                rockresponse.StatusCode   = response.StatusCode;
                rockresponse.JsonResponse = await response.Content.ReadAsStringAsync();

                rockresponse.Data = JsonConvert.DeserializeObject <List <T> >(rockresponse.JsonResponse);
                return(rockresponse);
            }
        }
Пример #2
0
        public virtual IRockResponse <S> Search <S>(BaseQO qo) where S : new()
        {
            if (string.IsNullOrWhiteSpace(SearchUrl))
            {
                throw new NotImplementedException("The property SearchUrl has no value on the ApiSet.");
            }
            var request = CreateRestRequest(Method.GET, SearchUrl);

            foreach (var pair in qo.ToDictionary())
            {
                request.AddQueryParameter(pair.Key, pair.Value);
            }

            var list = ExecuteCustomRequest <S>(request);

            return(list.ToRockResponse <S>());
        }
Пример #3
0
        public virtual IRockResponse <RockCollection <S> > FindBy <S>(BaseQO qo, string url = null) where S : new()
        {
            var collection = new RockCollection <S>();

            if (string.IsNullOrEmpty(url))
            {
                if (string.IsNullOrWhiteSpace(SearchUrl))
                {
                    throw new NotImplementedException("The property SearchUrl has no value on the ApiSet.");
                }
                url = SearchUrl;
            }

            var request = CreateRestRequest(Method.GET, url);

            foreach (var pair in qo.ToDictionary())
            {
                request.AddParameter(pair.Key, pair.Value);
            }

            var item = ExecuteCustomRequest <List <S> >(request);

            return(item.ToRockCollectionResponse());
        }
Пример #4
0
 public virtual IRockResponse <RockCollection <T> > FindBy(BaseQO qo)
 {
     return(FindBy <T>(qo));
 }
Пример #5
0
 public virtual IRockResponse <RockCollection <T> > FindBy(string parentID, BaseQO qo)
 {
     return(FindBy <T>(qo, string.Format(SearchUrl, parentID)));
 }