diff --git a/DataLayer/UNTESTED/EfClasses/Book.cs b/DataLayer/UNTESTED/EfClasses/Book.cs index fc224c0f..18d4f282 100644 --- a/DataLayer/UNTESTED/EfClasses/Book.cs +++ b/DataLayer/UNTESTED/EfClasses/Book.cs @@ -66,7 +66,7 @@ namespace DataLayer int lengthInMinutes, IEnumerable authors, IEnumerable narrators, - Category category) + Category category, string localeName) { // validate ArgumentValidator.EnsureNotNull(audibleProductId, nameof(audibleProductId)); @@ -75,6 +75,7 @@ namespace DataLayer // assign as soon as possible. stuff below relies on this AudibleProductId = productId; + Locale = localeName; ArgumentValidator.EnsureNotNullOrWhiteSpace(title, nameof(title)); @@ -243,6 +244,7 @@ namespace DataLayer Category = category; } + // needed for v3 => v4 upgrade public void UpdateLocale(string localeName) => Locale ??= localeName; diff --git a/DataLayer/UNTESTED/EfClasses/LibraryBook.cs b/DataLayer/UNTESTED/EfClasses/LibraryBook.cs index d299619f..e58e3929 100644 --- a/DataLayer/UNTESTED/EfClasses/LibraryBook.cs +++ b/DataLayer/UNTESTED/EfClasses/LibraryBook.cs @@ -14,13 +14,20 @@ namespace DataLayer public string Account { get; private set; } private LibraryBook() { } - public LibraryBook(Book book, DateTime dateAdded) + public LibraryBook(Book book, DateTime dateAdded, string account) { ArgumentValidator.EnsureNotNull(book, nameof(book)); + ArgumentValidator.EnsureNotNull(account, nameof(account)); + Book = book; DateAdded = dateAdded; + Account = account; } - public override string ToString() => $"{DateAdded:d} {Book}"; + // needed for v3 => v4 upgrade + public void UpdateAccount(string account) + => Account ??= account; + + public override string ToString() => $"{DateAdded:d} {Book}"; } } diff --git a/DtoImporterService/UNTESTED/BookImporter.cs b/DtoImporterService/UNTESTED/BookImporter.cs index cfaef4cc..89cbbdf7 100644 --- a/DtoImporterService/UNTESTED/BookImporter.cs +++ b/DtoImporterService/UNTESTED/BookImporter.cs @@ -105,7 +105,8 @@ namespace DtoImporterService item.LengthInMinutes, authors, narrators, - category) + category, + Account.Locale.Name) ).Entity; var publisherName = item.Publisher; @@ -129,6 +130,7 @@ namespace DtoImporterService book.PictureId = item.PictureId; book.UpdateProductRating(item.Product_OverallStars, item.Product_PerformanceStars, item.Product_StoryStars); + // needed during v3 => v4 migration book.UpdateLocale(Account.Locale.Name); // important to update user-specific info. this will have changed if user has rated/reviewed the book since last library import diff --git a/DtoImporterService/UNTESTED/LibraryImporter.cs b/DtoImporterService/UNTESTED/LibraryImporter.cs index 3e9184e7..752ddbc8 100644 --- a/DtoImporterService/UNTESTED/LibraryImporter.cs +++ b/DtoImporterService/UNTESTED/LibraryImporter.cs @@ -30,10 +30,16 @@ namespace DtoImporterService { var libraryBook = new LibraryBook( DbContext.Books.Local.Single(b => b.AudibleProductId == newItem.ProductId), - newItem.DateAdded); + newItem.DateAdded, + Account.AccountId); DbContext.Library.Add(libraryBook); } + // needed for v3 => v4 upgrade + var toUpdate = DbContext.Library.Where(l => l.Account == null); + foreach (var u in toUpdate) + u.UpdateAccount(Account.AccountId); + var qtyNew = newItems.Count; return qtyNew; } diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 75fdece5..2de56fb4 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 3.1.12.140 + 3.1.12.142