Пример #1
0
        //Gets posts and orders them by most popular, proxy method used, API call made to get all posts from db
        public async void GetPostInfo()
        {
            var temp = await _postsProxy.GetAllPosts(); //Makes the API call in the proxy

            if (temp != null)
            {
                if (temp.Count > 0)
                {
                    var orderedList = temp.OrderByDescending(x => x.UpVote.Count()); //Lambda expressions used to order posts by most popular (Via UpVote.Count)

                    foreach (var item in orderedList)                                //Foreach loop used to put each item from temp (List) into ObservableCollection
                    {
                        PostsMod.Add(item);
                        if (PostsMod.Count >= 10)
                        {
                            break;                       //Limits the amount of posts added to a max of 10, exits Foreach loop
                        }
                    }
                }
                else
                {
                    return;  //If temp is null, exit the method
                }
            }
        }