public virtual IRockResponse <RockCollection <T> > FindAll(int?page = null, int?pageSize = null) { var collection = new RockCollection <T>(); if (string.IsNullOrWhiteSpace(ListUrl)) { throw new NotImplementedException("The property ListUrl has no value on the ApiSet."); } var request = CreateRestRequest(Method.GET, ListUrl); if (page.HasValue && pageSize.HasValue) { request.AddParameter("$top", pageSize.Value); if (page.Value > 1) { request.AddParameter("$skip", pageSize.Value * (page.Value - 1)); } } var item = base.ExecuteListRequest(request); return(item.ToRockCollectionResponse()); }
public virtual IRockResponse <RockCollection <T> > FindAll(string parentID) { var collection = new RockCollection <T>(); if (string.IsNullOrWhiteSpace(GetChildListUrl)) { throw new NotImplementedException("The property GetChildListUrl has no value on the ApiSet."); } var request = CreateRestRequest(Method.GET, string.Format(GetChildListUrl, parentID)); var item = ExecuteListRequest(request); return(item.ToRockCollectionResponse()); }
public static IRockResponse <RockCollection <S> > ToRockCollectionResponse <S>(this IRestResponse <List <S> > restResponse, string requestInput = null) where S : new() { var response = new RockResponse <RockCollection <S> >(); response.StatusCode = restResponse.StatusCode; response.JsonResponse = restResponse.Content; if ((int)restResponse.StatusCode >= 300) { response.ErrorMessage = restResponse.ErrorMessage; } else { if (restResponse.Data != null) { var collection = new RockCollection <S>(); collection.Items.AddRange(restResponse.Data); response.Data = collection; } } return(response); }
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()); }