public async Task RemoveMainForumsList() { using (var ds = new DataSource()) { await ds.ForumCategoryRepository.RemoveAll(); await ds.ForumRepository.RemoveAll(); } }
public async override void Execute(object parameter) { var forumEntity = (ForumEntity) parameter; var realForumList = Locator.ViewModels.MainForumsPageVm.ForumGroupList.Where(node => !node.Name.Equals("Favorites")).SelectMany(node => node.ForumList); forumEntity = realForumList.FirstOrDefault(node => node.ForumId == forumEntity.ForumId); forumEntity.IsBookmarks = !forumEntity.IsBookmarks; var db = new DataSource(); await db.ForumRepository.Update(forumEntity); await Locator.ViewModels.MainForumsPageVm.GetFavoriteForums(); }
public async Task SaveMainForumsList(List<ForumCategoryEntity> forumGroupList) { using (var ds = new DataSource()) { var count = 1; foreach (var item in forumGroupList) { foreach (var forum in item.ForumList) { forum.Id = count; count++; } await ds.ForumCategoryRepository.CreateWithChildren(item); } } }
public async Task<List<ForumCategoryEntity>> GetMainForumsList() { using (var ds = new DataSource()) { var list = new List<ForumCategoryEntity>(); var dbForumsCategories = await ds.ForumCategoryRepository.GetAllWithChildren(); if (!dbForumsCategories.Any()) return list; var result = dbForumsCategories.OrderBy(node => node.Order); foreach (var forumCategoryEntity in result) { var testForumList = new List<ForumEntity>(); foreach (var forum in forumCategoryEntity.ForumList.Where(node => node.ParentForum == null)) { testForumList.Add(forum); ForumEntity forum1 = forum; testForumList.AddRange(forumCategoryEntity.ForumList.Where(node => node.ParentForum == forum1)); } forumCategoryEntity.ForumList = testForumList; list.Add(forumCategoryEntity); } return list; } }
public async Task<DraftEntity> LoadThreadDraftEntity(ForumThreadEntity thread) { using (var db = new DataSource()) { return await db.DraftRepository.Items.Where(node => node.ThreadId == thread.ThreadId).FirstOrDefaultAsync(); } }
public async Task SaveThreadReplyDraft(string replyText, ForumThreadEntity thread) { using (var db = new DataSource()) { var savedDraft = await db.DraftRepository.Items.Where(node => node.ThreadId == thread.ThreadId).FirstOrDefaultAsync(); if (savedDraft == null) { savedDraft = new DraftEntity() { ThreadId = thread.ThreadId, Draft = replyText, ForumId = thread.ForumId, NewThread = false, Id = thread.ThreadId }; await db.DraftRepository.Create(savedDraft); return; } savedDraft.Draft = replyText; await db.DraftRepository.Update(savedDraft); } }
public async Task RemoveAllThreadsFromTabList() { using (var db = new DataSource()) { await db.TabRepository.RemoveAll(); } }
public async Task<bool> DoesTabExist(ForumThreadEntity thread) { using (var db = new DataSource()) { var thread2 = db.TabRepository.Items.Where(node => node.ThreadId == thread.ThreadId); var test = await thread2.FirstOrDefaultAsync(); return test != null; } }
public async Task<List<ForumThreadEntity>> GetAllTabThreads() { using (var db = new DataSource()) { return await db.TabRepository.GetAllWithChildren(); } }
public async Task RemoveThreadFromTabListAsync(ForumThreadEntity thread) { using (var db = new DataSource()) { await db.TabRepository.Delete(thread); } }
public async Task AddThreadToTabListAsync(ForumThreadEntity thread) { using (var db = new DataSource()) { await db.TabRepository.Create(thread); } }
public async Task<List<ForumEntity>> GetFavoriteForumsAsync() { using (var ds = new DataSource()) { var list = new List<ForumEntity>(); var dbForumsCategories = await ds.ForumRepository.GetAllWithChildren(); if (!dbForumsCategories.Any()) return list; list.AddRange(dbForumsCategories.Where(node => node.IsBookmarks)); return list; } }