private async Task <List <ContentItemIdentifier> > GetAllUserItemIdentifiers() { List <ContentItemIdentifier> listIds = new List <ContentItemIdentifier>(); ListingResponseModel <ContentItemModel> response = await managementClient.ListContentItemsAsync(); // this is guid of Content Type "User" in the KC project ObjectIdentifier userContentType = new ObjectIdentifier() { Id = Guid.Parse("eaf7e4c9-0a4d-46dc-b787-ef02c9860592") }; while (true) { foreach (var item in response) { if (item.Type == userContentType) { listIds.Add(ContentItemIdentifier.ById(item.Id)); } } if (!response.HasNextPage()) { break; } response = await response.GetNextPage(); } return(listIds); }
private async Task <List <ContentItemModel> > GetAllItems() { int count = 0; List <ContentItemModel> itemList = new List <ContentItemModel> { }; logger.Debug("Request to get items from Kontent project.."); ListingResponseModel <ContentItemModel> response = await managementClient.ListContentItemsAsync(); logger.Debug("Got " + response.Count() + " items."); count += response.Count(); while (true) { foreach (var item in response) { itemList.Add(item); } if (!response.HasNextPage()) { logger.Debug("There are no more items to get."); break; } logger.Debug("Getting next page."); response = await response.GetNextPage(); count += response.Count(); logger.Debug("Got " + response.Count() + " items. Total: " + count); } return(itemList); }
private async Task <List <ContentItemIdentifier> > GetAllItemIdentifiers() { List <ContentItemIdentifier> listIds = new List <ContentItemIdentifier>(); ListingResponseModel <ContentItemModel> response = await managementClient.ListContentItemsAsync(); while (true) { foreach (var item in response) { listIds.Add(ContentItemIdentifier.ById(item.Id)); } if (!response.HasNextPage()) { break; } response = await response.GetNextPage(); } return(listIds); }