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

namespace MTWorkHR.Infrastructure.Repositories
{
    public class HubConnectionRepository : Repository<HubConnection>, IHubConnectionRepository
    {
        private readonly DbSet<HubConnection> dbSet;

        public HubConnectionRepository(HRDataContext context) : base(context)
        {
            dbSet = context.Set<HubConnection>();
        }

        public async Task<Tuple<IQueryable<HubConnection>, int>> GetAllAsync(string connectionId)
        {
            var query = dbSet.Where(c=> c.SignalrId == connectionId).AsQueryable();
            var total = await query.CountAsync();

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

        public async Task<Tuple<IQueryable<HubConnection>, int>> GetAllByUserAsync(string userId)
        {
            var query = dbSet.Where(c=> c.UserId == userId).AsQueryable();
            var total = await query.CountAsync();

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



    }
}
