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; } }
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; } }
/// <summary> /// Run the tally using the provided posts, for the selected quest. /// </summary> /// <param name="posts">The posts to be tallied.</param> /// <param name="quest">The quest being tallied.</param> /// <param name="token">Cancellation token.</param> public async Task TallyPosts(IEnumerable <PostComponents> posts, IQuest quest, CancellationToken token) { Quest = quest; PostsList.Clear(); PostsList.AddRange(posts); await TallyPosts(token).ConfigureAwait(false); }
/// <summary> /// Run the tally using the provided posts, for the selected quest. /// </summary> /// <param name="posts">The posts to be tallied.</param> /// <param name="quest">The quest being tallied.</param> /// <param name="token">Cancellation token.</param> public async Task TallyPosts(IEnumerable <PostComponents> posts, IQuest quest, CancellationToken token) { Quest = quest; PostsList.Clear(); PostsList.AddRange(posts); await TallyPosts(token).ConfigureAwait(false); OrderedTaskList.AddRange(ViewModelService.MainViewModel.KnownTasks); OnPropertyChanged("Tasks"); }