Beispiel #1
0
        //Gets all the posts comments, postId sent to proxy method, API call made to get all comments with the postId from db
        public async void GetCommentsInfo(string postId)
        {
            var temp = await _commentsProxy.GetCommentsByPost(postId); //Makes the API call in the proxy

            if (temp != null)
            {
                if (temp.Count >= 1)
                {
                    foreach (var item in temp) //Foreach loop used to put each item from temp (List) into ObservableCollection
                    {
                        CommentsList.Add(item);
                    }
                }
                else
                {
                    return;  //If temp is null, exit the method
                }
            }
        }
Beispiel #2
0
        } = new List <Comments>();                //The List for where we will store the data from api

        public async void GetCommentsInfo(int id) //this code is where the data from the api will be added to the list
        {
            var temp = await _commentsProxy.GetCommentsByPost(id);

            if (temp != null)
            {
                if (temp.Count > 1)
                {
                    foreach (var item in temp)
                    {
                        CommentsList.Add(item);
                    }
                }
                else
                {
                    return;
                }
            }
        }