using Insight.Infrastructure.Entities;
using Insight.Infrastructure.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using MongoDB.Driver;

namespace Insight.Infrastructure.Services
{
    public class CustomerService
    {
        private readonly IMongoDatabase _database;
        private readonly ILogger<CustomerService> _logger;

        public CustomerService(IMongoDatabase database, ILogger<CustomerService> logger)
        {
            _database = database;
            _logger = logger;
        }

        public Task<PagedList<CustomerEntity>> GetAsync(
            FilterDefinition<CustomerEntity>? filter = null,
            SortDefinition<CustomerEntity>? sort = null,
            int offset = 0,
            int limit = 10,
            CancellationToken cancellationToken = default) => _database.Customer().GetPagedAsync(filter, sort, offset, limit, cancellationToken);

        public Task<PagedList<CustomerEntity>> GetAsync(
            HttpRequest request,
            HttpResponse response,
            FilterDefinition<CustomerEntity>? filter = null,
            SortDefinition<CustomerEntity>? sort = null,
            int offset = 0,
            int limit = 10,
            CancellationToken cancellationToken = default) => _database.Customer().GetPagedAsync(request, response, filter, sort, offset, limit, cancellationToken);
    }
}