public async Task Filter(string Title) { try { var threadSearch = await _threadService.Post <IList <ThreadModel> >(new ThreadSearchRequest { Title = Title }, "search"); ThreadsList.Clear(); foreach (var item in threadSearch) { ThreadsList.Add(item); item.Comments = new ObservableCollection <CommentDto>(); var comments = await _commentsService.Get <IList <CommentDto> >(null, $"threads/{item.Id}"); comments.ForEach(x => { item.Comments.Add(x); }); } } catch (Exception) { throw; } }
public async Task Init() { try { ThreadsList.Clear(); IList <ThreadModel> posts = null; posts = await _threadService.Get <IList <ThreadModel> >(); foreach (var item in posts) { var data = await _commentsService.Get <IList <CommentDto> >(null, $"threads/{item.Id}"); item.Comments = new ObservableCollection <CommentDto>(data); ThreadsList.Add(item); } } catch { throw; } }