コード例 #1
0
        public async Task Filter(string Title)
        {
            try
            {
                var postSearch = await _postsService.Get <IList <PostModel> >(new PostSearchRequest
                {
                    Title = Title
                }, "search");

                PostsList.Clear();

                foreach (var item in postSearch)
                {
                    PostsList.Add(item);
                    item.Comments = new ObservableCollection <CommentDto>();

                    var comments = await _commentsService.Get <IList <CommentDto> >(null, $"posts/{item.Id}");

                    comments.ForEach(x =>
                    {
                        item.Comments.Add(x);
                    });
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        async void DoPostCommand()
        {
            if (CircleID != Constants.NoSelection)
            {
                try
                {
                    Post toAdd = new Post {
                        text = NewPost, user_id = UserID, circle_id = CircleID, created_at = DateTime.UtcNow, updated_at = DateTime.UtcNow
                    };
                    await _mLearningService.CreateObject <Post>(toAdd, p => p.id);

                    NewPost = "";

                    post_with_username puser = new post_with_username(toAdd);
                    puser.username = SessionService.GetUsername();

                    PostsList.Add(new post_with_username_wrapper {
                        post = puser, userImage = UserImage
                    });
                }
                catch (WebException e)
                {
                    ConnectionOK = false;
                }
            }
            else
            {
                //Notify Invalid Operation

                OperationOK = false;
            }
        }
コード例 #3
0
        public async Task Init()
        {
            try
            {
                PostsList.Clear();

                IList <PostModel> posts = null;

                if (!_blog)
                {
                    posts = await _postsService.Get <IList <PostModel> >();
                }
                else
                {
                    posts = await _postsService.Get <IList <PostModel> >(null, "followed");
                }

                foreach (var item in posts)
                {
                    //item.Comments = await _commentsService.Get<IList<CommentDto>>(null, $"posts/{item.Id}");
                    var data = await _commentsService.Get <IList <CommentDto> >(null, $"posts/{item.Id}");

                    item.Comments = new ObservableCollection <CommentDto>(data);
                    PostsList.Add(item);
                }
            }
            catch
            {
                throw;
            }
        }