using Diligent.WebAPI.Business.Services;
using Diligent.WebAPI.Data.Entities;
using Diligent.WebAPI.Host.Mediator.Rooms.Queries;
using MediatR;

namespace Diligent.WebAPI.Host.Mediator.Chat.Handlers
{
    public class GetAllRoomsWithFilteredMessagesHandler : IRequestHandler<GetAllRoomsWithFilteredMessagesQuery, List<Room>>
    {
        private readonly RoomService _roomService;

        public GetAllRoomsWithFilteredMessagesHandler(RoomService roomService)
        {
            _roomService = roomService;
        }
        public async Task<List<Room>> Handle(GetAllRoomsWithFilteredMessagesQuery request, CancellationToken cancellationToken)
        {
            var rooms = await _roomService.GetRoomsWithFilteredMessages(request.CustomerId);

            //if (rooms == null)
            //    throw new BadHttpRequestException("Please send a valid customer id");

            return rooms;

        }
    }
}
