HubConnectionRepository.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Microsoft.EntityFrameworkCore;
  2. using MTWorkHR.Core.Entities;
  3. using MTWorkHR.Core.IDto;
  4. using MTWorkHR.Infrastructure.Entities;
  5. using MTWorkHR.Infrastructure.DBContext;
  6. using MTWorkHR.Core.IRepositories;
  7. namespace MTWorkHR.Infrastructure.Repositories
  8. {
  9. public class HubConnectionRepository : Repository<HubConnection>, IHubConnectionRepository
  10. {
  11. private readonly DbSet<HubConnection> dbSet;
  12. public HubConnectionRepository(HRDataContext context) : base(context)
  13. {
  14. dbSet = context.Set<HubConnection>();
  15. }
  16. public async Task<Tuple<IQueryable<HubConnection>, int>> GetAllAsync(string connectionId)
  17. {
  18. var query = dbSet.Where(c=> c.SignalrId == connectionId).AsQueryable();
  19. var total = await query.CountAsync();
  20. return new Tuple<IQueryable<HubConnection>, int>(query, total);
  21. }
  22. public async Task<Tuple<IQueryable<HubConnection>, int>> GetAllByUserAsync(string userId)
  23. {
  24. var query = dbSet.Where(c=> c.UserId == userId).AsQueryable();
  25. var total = await query.CountAsync();
  26. return new Tuple<IQueryable<HubConnection>, int>(query, total);
  27. }
  28. }
  29. }