Пример #1
0
        /// <summary>
        ///     Gets the first amount of Jodels Async (internal usage)
        /// </summary>
        /// <returns>List&lt;Jodels&gt;.</returns>
        public async Task <List <Jodels> > GetFirstJodelsAsync()
        {
            string plainJson;

            using (var client = new MyWebClient())
            {
                client.Encoding = Encoding.UTF8;
                plainJson       = await client.DownloadStringTaskAsync(new Uri(Constants.LinkFirstJodels.ToLink()));
            }
            JsonJodelsFirstRound.RootObject jfr =
                JsonConvert.DeserializeObject <JsonJodelsFirstRound.RootObject>(plainJson);
            List <Jodels> temp = new List <Jodels>(); // List<post_id,message>

            foreach (var item in jfr.recent)
            {
                string image_url = "";
                bool   isUrl     = false;

                if (item.image_url != null)
                {
                    image_url = "http:" + item.image_url;
                    isUrl     = true;
                }

                Jodels objJodels = new Jodels
                {
                    PostId                = item.post_id,
                    Message               = item.message,
                    HexColor              = item.color,
                    IsImage               = isUrl,
                    ImageUrl              = image_url,
                    VoteCount             = item.vote_count,
                    LocationName          = item.location.name,
                    CommentsCount         = item.child_count ?? 0,
                    ChildCount            = item.child_count ?? 0,
                    CreatedAt             = DateTime.ParseExact(item.created_at.Replace("Z", "").Replace("T", " "), "yyyy-MM-dd HH:mm:ss.fff", null),
                    UpdatedAt             = DateTime.ParseExact(item.updated_at.Replace("Z", "").Replace("T", " "), "yyyy-MM-dd HH:mm:ss.fff", null),
                    Distance              = item.distance,
                    IsNotificationEnabled = item.notifications_enabled,
                    PinCount              = item.pin_count,
                    PostOwn               = item.post_own,
                    UserHandle            = item.user_handle
                };

                temp.Add(objJodels);
            }

            lock (_lastPostId)
            {
                _lastPostId = temp.Last().PostId; // Set the last post_id for next jodels
            }

            return(temp);
        }
Пример #2
0
        public JodelMainData GetPostChannelCombo(string channel, bool home = false)
        {
            string jsonString = Links.GetChannelCombo.ExecuteRequest(Account, new Dictionary <string, string>
            {
                { "channel", channel },
                { "home", home.ToString().ToLower() }
            });

            JsonJodelsFirstRound.RootObject jodels = JsonConvert.DeserializeObject <JsonJodelsFirstRound.RootObject>(jsonString);
            JodelMainData data = new JodelMainData {
                Max = jodels.max
            };

            data.RecentJodels.AddRange(jodels.recent.Select(r => new JodelPost(r)));
            data.RepliedJodels.AddRange(jodels.replied.Select(r => new JodelPost(r)));
            data.VotedJodels.AddRange(jodels.voted.Select(v => new JodelPost(v)));
            return(data);
        }
Пример #3
0
        public JodelMainData GetPostLocationCombo(bool stickies = false, bool home = false)
        {
            string jsonString = Links.GetPostsCombo.ExecuteRequest(Account, new Dictionary <string, string>
            {
                { "lat", Account.Place.Latitude.ToString("F", CultureInfo.InvariantCulture) },
                { "lng", Account.Place.Longitude.ToString("F", CultureInfo.InvariantCulture) },
                { "stickies", stickies.ToString().ToLower() },
                { "home", home.ToString().ToLower() }
            });

            JsonJodelsFirstRound.RootObject jodels = JsonConvert.DeserializeObject <JsonJodelsFirstRound.RootObject>(jsonString);
            JodelMainData data = new JodelMainData {
                Max = jodels.max
            };

            data.RecentJodels.AddRange(jodels.recent.Select(r => new JodelPost(r)));
            data.RepliedJodels.AddRange(jodels.replied.Select(r => new JodelPost(r)));
            data.VotedJodels.AddRange(jodels.voted.Select(v => new JodelPost(v)));
            return(data);
        }