Exemplo n.º 1
0
    public async Task <IActionResult> Export(
        CancellationToken cancellationToken = default)
    {
        var contents = new List <Content>();

        var pagedContents = new SearchResponse <Content>
        {
            Skip = -100,
            Take = 100,
        };

        do
        {
            pagedContents.Skip += pagedContents.Take;

            pagedContents = await ContentAccessor
                            .SearchContentAsync(
                new ContentSearchRequest(),
                pagedContents.Skip,
                pagedContents.Take,
                cancellationToken);

            contents.AddRange(pagedContents.Items);
        }while (pagedContents.TotalCount >=
                pagedContents.Skip + pagedContents.Take);

        return(Ok(contents));
    }