Remove items from library.
This commit is contained in:
parent
5d4bcb2db0
commit
00f7e4b779
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user