public async Task <bool> RemoveItemAsync(int blogEntry) { bool status = await DataProvider.RemoveAsync(blogEntry); if (!status) { return(false); } // remove comments for this entry using (BlogCommentDataProvider commentDP = new BlogCommentDataProvider(blogEntry)) { await commentDP.RemoveAllCommentsAsync(); } return(true); }
public async Task <bool> RemoveEntriesAsync(int categoryIdentity) { // TODO: This could be optimized for SQL using joins %%%%%%%%%%%%%%%%%%% // remove all entries for this category List <DataProviderFilterInfo> filters = DataProviderFilterInfo.Join(null, new DataProviderFilterInfo { Field = nameof(BlogEntry.CategoryIdentity), Operator = "==", Value = categoryIdentity }); DataProviderGetRecords <BlogEntry> data = await GetItemsAsync(0, 0, null, filters); foreach (BlogEntry entry in data.Data) { // remove all comments using (BlogCommentDataProvider commentDP = new BlogCommentDataProvider(entry.Identity)) { await commentDP.RemoveAllCommentsAsync(); } } return(true); }
// ISEARCHDYNAMICURLS // ISEARCHDYNAMICURLS // ISEARCHDYNAMICURLS public async Task KeywordsForDynamicUrlsAsync(ISearchWords searchWords) { using (this) { BlogConfigData config = await BlogConfigDataProvider.GetConfigAsync(); List <DataProviderFilterInfo> filters = DataProviderFilterInfo.Join(null, new DataProviderFilterInfo { Field = nameof(BlogEntry.Published), Operator = "==", Value = true }); DataProviderGetRecords <BlogEntry> entries = await GetItemsAsync(0, 0, null, filters); foreach (BlogEntry entry in entries.Data) { string url = await BlogConfigData.GetEntryCanonicalNameAsync(entry.Identity); PageDefinition page = await PageDefinition.LoadFromUrlAsync(url); if (page == null) { return; // there is no such root page } if (!searchWords.WantPage(page)) { return; } if (await searchWords.SetUrlAsync(url, page.PageSecurity, entry.Title, entry.DisplayableSummaryText, entry.DateCreated, entry.DateUpdated, page.IsAuthorized_View_Anonymous(), page.IsAuthorized_View_AnyUser())) { searchWords.AddObjectContents(entry); using (BlogCommentDataProvider commentDP = new BlogCommentDataProvider(entry.Identity)) { DataProviderGetRecords <BlogComment> comments = await commentDP.GetItemsAsync(0, 0, null, null); foreach (BlogComment comment in comments.Data) { searchWords.AddObjectContents(comment); } } await searchWords.SaveAsync(); } } } }