public async Task GetFavoriteForums() { var forumEntities = await _db.GetFavoriteForumsAsync(); var favorites = ForumGroupList.FirstOrDefault(node => node.Name.Equals("Favorites")); if (!forumEntities.Any()) { if (favorites != null) { ForumGroupList.Remove(favorites); } OnPropertyChanged("ForumGroupList"); return; } _favoritesEntity = new ForumCategoryEntity { Name = "Favorites", Location = string.Format(Constants.ForumPage, "forumid=48"), ForumList = forumEntities }; if (favorites == null) { ForumGroupList.Insert(0, _favoritesEntity); } else { ForumGroupList.RemoveAt(0); ForumGroupList.Insert(0, _favoritesEntity); } OnPropertyChanged("ForumGroupList"); }
public async Task Initialize() { IsLoading = true; try { _searchManager = new SearchManager(); var forumCategoryEntities = await _forumManager.GetForumCategoryMainPage(); foreach (var forumCategoryEntity in forumCategoryEntities) { ForumGroupList.Add(forumCategoryEntity); } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get forums list", ex); } IsLoading = false; }
private void GetFavoriteForums() { if (!_localSettings.Values.ContainsKey("_forumIds")) { return; } DeserializeXmlToList((string)_localSettings.Values["_forumIds"]); var forumEntities = new List <ForumEntity>(); foreach (var f in ForumGroupList.Select(forumGroup => forumGroup.ForumList.Where(forum => _forumIds.Contains(forum.ForumId)).ToList())) { forumEntities.AddRange(f); } _favoritesEntity = new ForumCategoryEntity("Favorites", "forumid=48") { ForumList = forumEntities }; SetFavoriteForums(new ObservableCollection <ForumCategoryEntity> { _favoritesEntity }); }
private async Task GetMainPageForumsAsync() { var forumCategoryEntities = await _db.GetMainForumsList(); if (forumCategoryEntities.Any()) { foreach (var forumCategoryEntity in forumCategoryEntities) { ForumGroupList.Add(forumCategoryEntity); } #if DEBUG ForumGroupList[3].ForumList.Add(ForumManager.AddDebugForum()); #endif return; } forumCategoryEntities = await _forumManager.GetForumCategoryMainPage(); foreach (var forumCategoryEntity in forumCategoryEntities) { ForumGroupList.Add(forumCategoryEntity); } await _db.SaveMainForumsList(ForumGroupList.ToList()); }