using Microsoft.EntityFrameworkCore;
using MTWorkHR.Core.Entities;
using MTWorkHR.Core.IRepositories;
using MTWorkHR.Infrastructure.DBContext;

namespace MTWorkHR.Infrastructure.Repositories
{
    public class InvoiceRepository : Repository<Invoice>, IInvoiceRepository
    {
        private readonly DbSet<Invoice> dbSet;

        public InvoiceRepository(HRDataContext context) : base(context)
        {
            dbSet = context.Set<Invoice>();

        }

        public async Task<Tuple<IQueryable<Invoice>, int>> GetAllUserInvoices(long contractId)
        {
            var query = dbSet.Where(a => a.ContractId == contractId).AsQueryable();
            var total = await query.CountAsync();

            return new Tuple<IQueryable<Invoice>, int>(query, total);
        }
    }
}