コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }