Exemplo n.º 1
0
        public async Task <IActionResult> GetLive()
        {
            List <Channel> channels = await _crudRepository.GetAll <Channel>();

            List <string> channelNames = channels.Select(x => x.Name).ToList();
            var           liveChannels = await _twitchService.GetLiveChannels(channelNames);

            return(Ok(liveChannels));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get()
        {
            // TODO: Do this better. Extract and remove duplication.
            List <Channel> channels = await _crudRepository.GetAll <Channel>();

            List <string> channelNames = channels.Select(x => x.Name).ToList();
            var           liveChannels = await _twitchService.GetLiveChannels(channelNames);

            return(Ok(liveChannels));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync()
        {
            // TODO: Don't pull the data like this....
            List <Channel> channels = await _repo.GetAll <Channel>();

            List <string> channelNames     = channels.Select(x => x.Name).ToList();
            var           liveChannelNames = await _twitchService.GetLiveChannels(channelNames);

            LiveChannels = channels
                           .Where(x => liveChannelNames.Contains(x.Name))
                           .Select(x => x.ToChannelIndexModel())
                           .ToList();

            NewlyAddedChannels = channels
                                 .Take(5)
                                 .Select(x => x.ToChannelIndexModel())
                                 .ToList();

            return(Page());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnGetLuckyAsync()
        {
            List <Channel> channels = await _repo.GetAll <Channel>();

            List <string> channelNames = channels.Select(x => x.Name).ToList();
            var           liveChannels = await _twitchService.GetLiveChannels(channelNames);

            var result = new Result();

            if (liveChannels.Any())
            {
                result.ChannelName = liveChannels.PickOneRandomElement();
            }
            else
            {
                result.Error = "No live channels available right now, try again later!";
            }

            return(new JsonResult(result));
        }