public async Task <Operation <List <Channel> > > GetSubscribedChannels(string deviceId)
        {
            Operation <List <Channel> > op = new Operation <List <Channel> >()
            {
                IsValid = true
            };

            var channelIds = await _channelsService.GetSubscribedChannelIdsAsync(deviceId);

            if (channelIds == null || !channelIds.Any())
            {
                op.ErrorMessages.Add("No channels found");
                return(op);
            }

            var channels = await _channelsService.GetChannelsAsync();

            var channelsSubscribed = from a in channels
                                     join b in channelIds
                                     on a.Id equals b
                                     select a;

            op.Payload = channelsSubscribed.ToList();

            return(op);
        }
        public async Task <Operation <List <Event> > > GetEventsAsync(string deviceId, string channelId, CancellationToken ct = default(CancellationToken))
        {
            Operation <List <Event> > op = new Operation <List <Event> >()
            {
                IsValid       = true,
                ErrorMessages = new List <string>()
            };

            DateTime dtNow = DateTime.Now;

            DateTime start = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 0, 0, 0);
            DateTime end   = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 23, 59, 59);

            var subscribedChannels = await _channelsService.GetSubscribedChannelIdsAsync(deviceId);

            var channels = await _channelsService.GetChannelsAsync();

            var channelName = channels.Where(x => x.Id == channelId).Select(x => x.Name).FirstOrDefault();

            bool isSubscribed = subscribedChannels.Any(x => x == channelId);

            var programs = await _programsService.GetAllProgramsAsync();

            var events = programs.Where(x => x.StartTime >= start && x.EndTime <= end).Select(x => CreateEvent(x, isSubscribed, channelName));


            if (!events.Any())
            {
                op.ErrorMessages.Add("No events found");
                return(op);
            }

            op.Payload = events.ToList();

            return(op);
        }
        public void GetChannels_ShouldRetrieveChannelsByDeviceId()
        {
            var channelIds = _channelsService.GetSubscribedChannelIdsAsync("device-001").Result;

            Assert.IsTrue(channelIds.Any());
        }