Remove items from library.

This commit is contained in:
Michael Bucari-Tovo 2021-07-02 14:07:42 -06:00
parent 5d4bcb2db0
commit 00f7e4b779

View File

@ -35,7 +35,10 @@ namespace DtoImporterService
// CURRENT SOLUTION: don't re-insert
var currentLibraryProductIds = DbContext.Library.Select(l => l.Book.AudibleProductId);
var audibleLibraryProductIds = importItems.Select(i => i.DtoItem.ProductId);
var newItems = importItems.Where(dto => !currentLibraryProductIds.Contains(dto.DtoItem.ProductId));
var removedItems = DbContext.Library.Where(l => !audibleLibraryProductIds.Contains(l.Book.AudibleProductId));
foreach (var newItem in newItems)
{
@ -55,7 +58,10 @@ namespace DtoImporterService
u.UpdateAccount(item.AccountId);
}
DbContext.Library.RemoveRange(removedItems);
var qtyNew = newItems.Count();
var qtyRemoved = removedItems.Count();
return qtyNew;
}
}