protected override async Task<bool> GetDataAsync() { var resource = new ProductReservationResource(Context); _results = await resource.GetProductReservationsAsync(startIndex: StartIndex, pageSize: PageSize, sortBy: SortBy, filter: Filter, responseFields: ResponseFields); TotalCount = _results.TotalCount; PageCount = _results.PageCount; PageSize = _results.PageSize; return _results.Items != null && _results.Items.Count > 0; }
#pragma warning disable 618 #region GetProductReservations public ProductReservation[] GetProductReservations(MozuContext ctx, string filter = null) { List<ProductReservation> list = new List<ProductReservation>(); ProductReservationResource resource = new ProductReservationResource(ctx.GetApiContext()); int pageSize = 1000; // will clamp to 200 int startIndex = 0; int pageCount = 0; int currentPage = 0; do { ProductReservationCollection collection = resource.GetProductReservations(pageSize: pageSize, startIndex: startIndex, filter: filter); if (collection == null || collection.Items == null || collection.Items.Count < 1) { return null; } if (collection.PageSize != pageSize) { // clamp our page size if it was too big pageSize = collection.PageSize; } if (pageCount == 0) { pageCount = collection.PageCount; } foreach (ProductReservation p in collection.Items) { list.Add(p); } currentPage++; startIndex += pageSize; } while (currentPage < pageCount); return list.ToArray(); }