public async Task LoadPosts() { AllPosts.Clear(); var posts = await _postApiService.Get <IEnumerable <MPost> >(); List <MPost> lists = posts.Where(x => x.User.Id == APIService.LoggedUser.Id).ToList(); foreach (var item in lists) { AllPosts.Add(item); } }
public async Task LoadPosts() { AllPosts.Clear(); var posts = await _postApiService.Get <IEnumerable <MPost> >(); if (SelectedOption != null) { switch (SelectedOption) { case "AtoZ": List <MPost> listAtoZ = posts.OrderBy(x => x.Title).ToList(); foreach (var item in listAtoZ) { AllPosts.Add(item); } break; case "Category": List <MPost> listCategory = posts.OrderBy(x => x.Category.Id).ToList(); foreach (var item in listCategory) { AllPosts.Add(item); } break; case "Date": List <MPost> listDate = posts.OrderBy(x => x.CreationDate).ToList(); foreach (var item in listDate) { AllPosts.Add(item); } break; } } else { List <MPost> lists = posts.OrderByDescending(x => x.Id).ToList(); foreach (var item in lists) { AllPosts.Add(item); } } }