/// <summary> /// Get's all Jodels from this channel. /// </summary> /// <param name="channel">The channel.</param> /// <returns>List<ChannelJodel>.</returns> public List <ChannelJodel> GetJodels(string channel) { string plainJson; using (var client = new MyWebClient()) { client.Encoding = Encoding.UTF8; plainJson = client.DownloadString(Constants.LinkGetJodelsFromChannel.ToLink(channel)); } JsonGetJodelsFromChannel.RootObject myJodelsFromChannel = JsonConvert.DeserializeObject <JsonGetJodelsFromChannel.RootObject>(plainJson); return(myJodelsFromChannel.recent.Select(item => new ChannelJodel { PostId = item.post_id, Message = item.message, VoteCount = item.vote_count, PinCount = item.pin_count, IsOwn = item.post_own.Equals("own") }).ToList()); }
/// <summary> /// Get's all Jodels from this channel. /// </summary> /// <param name="channel">The channel.</param> /// <returns>List<ChannelJodel>.</returns> public async Task <List <ChannelJodel> > GetJodelsAsync() { string plainJson; using (var client = new MyWebClient()) { client.Encoding = Encoding.UTF8; var taskResult = await Task.FromResult( client.DownloadStringTaskAsync(new Uri(Constants.LinkGetJodelsFromChannel.ToLink(ChannelName)))); plainJson = taskResult.Result; } JsonGetJodelsFromChannel.RootObject myJodelsFromChannel = JsonConvert.DeserializeObject <JsonGetJodelsFromChannel.RootObject>(plainJson); return(myJodelsFromChannel.recent.Select(item => new ChannelJodel { PostId = item.post_id, Message = item.message, VoteCount = item.vote_count, PinCount = item.pin_count, IsOwn = item.post_own.Equals("own") }).ToList()); }