InvoiceRepository.cs 793 B

123456789101112131415161718192021222324252627
  1. using Microsoft.EntityFrameworkCore;
  2. using MTWorkHR.Core.Entities;
  3. using MTWorkHR.Core.IRepositories;
  4. using MTWorkHR.Infrastructure.DBContext;
  5. namespace MTWorkHR.Infrastructure.Repositories
  6. {
  7. public class InvoiceRepository : Repository<Invoice>, IInvoiceRepository
  8. {
  9. private readonly DbSet<Invoice> dbSet;
  10. public InvoiceRepository(HRDataContext context) : base(context)
  11. {
  12. dbSet = context.Set<Invoice>();
  13. }
  14. public async Task<Tuple<IQueryable<Invoice>, int>> GetAllUserInvoices(long contractId)
  15. {
  16. var query = dbSet.Where(a => a.ContractId == contractId).AsQueryable();
  17. var total = await query.CountAsync();
  18. return new Tuple<IQueryable<Invoice>, int>(query, total);
  19. }
  20. }
  21. }