Cleanup bookmarks and Reading List Items (#567)

* Removed directives, ensured we delete bookmarks and reading list items when chapters are deleted.

* Added parsing support for "Kimi no Koto ga Daidaidaidaidaisuki na 100-nin no Kanojo Chapter 11-10"
This commit is contained in:
Joseph Milazzo 2021-09-08 14:41:41 -07:00 committed by GitHub
parent 6c07246980
commit c718e45f4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 27 additions and 22 deletions

View file

@ -1,7 +1,6 @@
using System.Linq;
using System.Threading.Tasks;
using API.Entities.Enums;
using API.Interfaces;
using API.Interfaces.Repositories;
using Microsoft.EntityFrameworkCore;
@ -27,7 +26,17 @@ namespace API.Data.Repositories
.Where(progress => !chapterIds.Contains(progress.ChapterId))
.ToListAsync();
var rowsToRemoveBookmarks = await _context.AppUserBookmark
.Where(progress => !chapterIds.Contains(progress.ChapterId))
.ToListAsync();
var rowsToRemoveReadingLists = await _context.ReadingListItem
.Where(item => !chapterIds.Contains(item.ChapterId))
.ToListAsync();
_context.RemoveRange(rowsToRemove);
_context.RemoveRange(rowsToRemoveBookmarks);
_context.RemoveRange(rowsToRemoveReadingLists);
return await _context.SaveChangesAsync() > 0 ? rowsToRemove.Count : 0;
}