using ConstructorApp.BusinessLayer.Abstract;
using Microsoft.AspNetCore.SignalR;

namespace ConstructorAppApi.Hubs
{
    public class SignalRHub : Hub
    {
        private readonly ITestimonialService _testimonialService;
        private readonly IContactUsService _contactUsService;
        private readonly IProjectService _projectService;
        private readonly IReferenceService _referenceService ;

        public SignalRHub(ITestimonialService testimonialService, IContactUsService contactUsService, IProjectService projectService, IReferenceService referenceService)
        {
            _testimonialService = testimonialService;
            _contactUsService = contactUsService;
            _projectService = projectService;
            _referenceService = referenceService;
        }

        public async Task SendTestimonial()
        {
            var values = _testimonialService.TCountAll();
            await Clients.All.SendAsync("ReceiveTestimonialCountAll", values);
        }

        public async Task SendContactUs()
        {
            var values = _contactUsService.TCountByStatusPending();
            await Clients.All.SendAsync("ReceiveContactUsCountByStatusPending", values);

            var values1 = _contactUsService.TCountAll();
            await Clients.All.SendAsync("ReceiveContactUsCountAll", values1);
        }

        public async Task SendProject()
        {
            var value = _projectService.TCountAll();
            await Clients.All.SendAsync("ReceiveProjectCountAll", value);
        }

        public async Task SendReference()
        {
            var value = _referenceService.TCountAll();
            await Clients.All.SendAsync("ReceiveReferenceCountAll", value);
        }
    }
}
