using Insight.Infrastructure.Models; using Microsoft.AspNetCore.Http; using MongoDB.Bson; using MongoDB.Driver; namespace Insight.Infrastructure.Web; public static class MongoCollectionExtensions { public static async Task> GetPagedAsync( this IMongoCollection collection, HttpRequest request, HttpResponse response, FilterDefinition? filter = null, SortDefinition? sort = null, int offset = 0, int limit = 10, CancellationToken cancellationToken = default) { var result = await Infrastructure.MongoCollectionExtensions.GetPagedAsync(collection, filter, sort, offset, limit, cancellationToken).ConfigureAwait(false); request?.AddPagination(result); response?.AddPagination(result); return result; } public static async Task> GetPagedAsync( this IMongoCollection collection, HttpRequest request, HttpResponse response, IAggregateFluent query, int offset = 0, int limit = 10, CancellationToken cancellationToken = default) { var result = await Infrastructure.MongoCollectionExtensions.GetPagedAsync(collection, query, offset, limit, cancellationToken).ConfigureAwait(false); request?.AddPagination(result); response?.AddPagination(result); return result; } }