예제 #1
0
        //public static string GetChannelVideos(string channelId, string nextPage)
        //{

        //    string maxResults = "10";
        //    var httpClient = new HttpClient();
        //    string query = "https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=" +
        //        channelId + "&pageToken=" +
        //        nextPage + "&safeSearch=strict&maxResults=" +
        //        maxResults + "&type=video&key=" +
        //        Constants.ApiKey;
        //    string result = httpClient.GetStringAsync(query).Result;

        //    return result;
        //}

        //public static async Task<IEnumerable<Channel>> GetThreeGroups()
        //{
        //    if (_sampleDataSource._groups.Count == 0)
        //    {
        //        await GetChannelsAsync();
        //    }
        //    var justThree = new ObservableCollection<Channel>();

        //    int numOfChannels = _sampleDataSource.Groups.Count;

        //    Random random = new Random();
        //    for (int index = 0; index < 3; index++)
        //    {

        //        int rando = random.Next(numOfChannels) + 1;
        //        if (_sampleDataSource.Groups.ElementAt(rando).Videos.Count == 0)
        //        {
        //            loadVideos(_sampleDataSource._groups.ElementAt(rando).Id);
        //        }
        //        justThree.Add(_sampleDataSource.Groups.ElementAt(rando));
        //    }


        //    return justThree;
        //}

        public static async void deleteChannel(int index)
        {
            string channelId = _channelDataSource.Groups.ElementAt(index).Id;

            _channelDataSource.Groups.RemoveAt(index);

            string localData = await ReadUserFile();

            localData = localData.Replace(channelId, string.Empty);

            await ChannelDataSource.saveChannelIdToFile(localData);
        }
예제 #2
0
        public static async Task <string> addChannel(Channel channel)
        {
            for (int i = 0; i < _channelDataSource.Groups.Count; i++)
            {
                if (_channelDataSource.Groups.ElementAt(i).Id == channel.Id)
                {
                    return("The channel is already in your list");
                }
            }

            _channelDataSource.Groups.Add(channel);
            string localData = await ReadUserFile();

            localData = localData + "," + channel.Id;

            await ChannelDataSource.saveChannelIdToFile(localData);

            return("Added channel " + channel.Title);
        }