diff --git a/DataLayer/LibationContext.db b/DataLayer/LibationContext.db new file mode 100644 index 00000000..cd2ca5e8 Binary files /dev/null and b/DataLayer/LibationContext.db differ diff --git a/DataLayer/Migrations/20191115193402_Fresh.Designer.cs b/DataLayer/Migrations/20191119144803_Fresh.Designer.cs similarity index 72% rename from DataLayer/Migrations/20191115193402_Fresh.Designer.cs rename to DataLayer/Migrations/20191119144803_Fresh.Designer.cs index 3eb401de..b3d720fe 100644 --- a/DataLayer/Migrations/20191115193402_Fresh.Designer.cs +++ b/DataLayer/Migrations/20191119144803_Fresh.Designer.cs @@ -3,54 +3,50 @@ using System; using DataLayer; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataLayer.Migrations { [DbContext(typeof(LibationContext))] - [Migration("20191115193402_Fresh")] + [Migration("20191119144803_Fresh")] partial class Fresh { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasAnnotation("ProductVersion", "3.0.0"); modelBuilder.Entity("DataLayer.Book", b => { b.Property("BookId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b.Property("AudibleProductId") - .HasColumnType("nvarchar(450)"); + .HasColumnType("TEXT"); b.Property("CategoryId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("DatePublished") - .HasColumnType("datetime2"); + .HasColumnType("TEXT"); b.Property("Description") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.Property("IsAbridged") - .HasColumnType("bit"); + .HasColumnType("INTEGER"); b.Property("LengthInMinutes") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("PictureId") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.Property("Title") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.HasKey("BookId"); @@ -64,16 +60,16 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.BookContributor", b => { b.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("ContributorId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("Role") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("Order") - .HasColumnType("tinyint"); + .HasColumnType("INTEGER"); b.HasKey("BookId", "ContributorId", "Role"); @@ -88,17 +84,16 @@ namespace DataLayer.Migrations { b.Property("CategoryId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b.Property("AudibleCategoryId") - .HasColumnType("nvarchar(450)"); + .HasColumnType("TEXT"); b.Property("Name") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.Property("ParentCategoryCategoryId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.HasKey("CategoryId"); @@ -121,14 +116,13 @@ namespace DataLayer.Migrations { b.Property("ContributorId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); - b.Property("AudibleAuthorId") - .HasColumnType("nvarchar(max)"); + b.Property("AudibleContributorId") + .HasColumnType("TEXT"); b.Property("Name") - .HasColumnType("nvarchar(450)"); + .HasColumnType("TEXT"); b.HasKey("ContributorId"); @@ -140,10 +134,10 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.LibraryBook", b => { b.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("DateAdded") - .HasColumnType("datetime2"); + .HasColumnType("TEXT"); b.HasKey("BookId"); @@ -154,14 +148,13 @@ namespace DataLayer.Migrations { b.Property("SeriesId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b.Property("AudibleSeriesId") - .HasColumnType("nvarchar(450)"); + .HasColumnType("TEXT"); b.Property("Name") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.HasKey("SeriesId"); @@ -173,13 +166,13 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.SeriesBook", b => { b.Property("SeriesId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("Index") - .HasColumnType("real"); + .HasColumnType("REAL"); b.HasKey("SeriesId", "BookId"); @@ -201,18 +194,16 @@ namespace DataLayer.Migrations b.OwnsOne("DataLayer.Rating", "Rating", b1 => { b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b1.Property("OverallRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b1.Property("PerformanceRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b1.Property("StoryRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b1.HasKey("BookId"); @@ -226,14 +217,13 @@ namespace DataLayer.Migrations { b1.Property("SupplementId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b1.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b1.Property("Url") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b1.HasKey("SupplementId"); @@ -248,10 +238,10 @@ namespace DataLayer.Migrations b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => { b1.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b1.Property("Tags") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b1.HasKey("BookId"); @@ -263,16 +253,16 @@ namespace DataLayer.Migrations b1.OwnsOne("DataLayer.Rating", "Rating", b2 => { b2.Property("UserDefinedItemBookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b2.Property("OverallRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b2.Property("PerformanceRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b2.Property("StoryRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b2.HasKey("UserDefinedItemBookId"); diff --git a/DataLayer/Migrations/20191115193402_Fresh.cs b/DataLayer/Migrations/20191119144803_Fresh.cs similarity index 96% rename from DataLayer/Migrations/20191115193402_Fresh.cs rename to DataLayer/Migrations/20191119144803_Fresh.cs index ccc37c52..78fe47a7 100644 --- a/DataLayer/Migrations/20191115193402_Fresh.cs +++ b/DataLayer/Migrations/20191119144803_Fresh.cs @@ -12,7 +12,7 @@ namespace DataLayer.Migrations columns: table => new { CategoryId = table.Column(nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), + .Annotation("Sqlite:Autoincrement", true), AudibleCategoryId = table.Column(nullable: true), Name = table.Column(nullable: true), ParentCategoryCategoryId = table.Column(nullable: true) @@ -33,9 +33,9 @@ namespace DataLayer.Migrations columns: table => new { ContributorId = table.Column(nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), + .Annotation("Sqlite:Autoincrement", true), Name = table.Column(nullable: true), - AudibleAuthorId = table.Column(nullable: true) + AudibleContributorId = table.Column(nullable: true) }, constraints: table => { @@ -47,7 +47,7 @@ namespace DataLayer.Migrations columns: table => new { SeriesId = table.Column(nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), + .Annotation("Sqlite:Autoincrement", true), AudibleSeriesId = table.Column(nullable: true), Name = table.Column(nullable: true) }, @@ -61,7 +61,7 @@ namespace DataLayer.Migrations columns: table => new { BookId = table.Column(nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), + .Annotation("Sqlite:Autoincrement", true), AudibleProductId = table.Column(nullable: true), Title = table.Column(nullable: true), Description = table.Column(nullable: true), @@ -159,7 +159,7 @@ namespace DataLayer.Migrations columns: table => new { SupplementId = table.Column(nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), + .Annotation("Sqlite:Autoincrement", true), BookId = table.Column(nullable: false), Url = table.Column(nullable: true) }, diff --git a/DataLayer/Migrations/LibationContextModelSnapshot.cs b/DataLayer/Migrations/LibationContextModelSnapshot.cs index dcefe353..262933d6 100644 --- a/DataLayer/Migrations/LibationContextModelSnapshot.cs +++ b/DataLayer/Migrations/LibationContextModelSnapshot.cs @@ -3,7 +3,6 @@ using System; using DataLayer; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataLayer.Migrations @@ -15,40 +14,37 @@ namespace DataLayer.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasAnnotation("ProductVersion", "3.0.0"); modelBuilder.Entity("DataLayer.Book", b => { b.Property("BookId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b.Property("AudibleProductId") - .HasColumnType("nvarchar(450)"); + .HasColumnType("TEXT"); b.Property("CategoryId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("DatePublished") - .HasColumnType("datetime2"); + .HasColumnType("TEXT"); b.Property("Description") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.Property("IsAbridged") - .HasColumnType("bit"); + .HasColumnType("INTEGER"); b.Property("LengthInMinutes") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("PictureId") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.Property("Title") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.HasKey("BookId"); @@ -62,16 +58,16 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.BookContributor", b => { b.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("ContributorId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("Role") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("Order") - .HasColumnType("tinyint"); + .HasColumnType("INTEGER"); b.HasKey("BookId", "ContributorId", "Role"); @@ -86,17 +82,16 @@ namespace DataLayer.Migrations { b.Property("CategoryId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b.Property("AudibleCategoryId") - .HasColumnType("nvarchar(450)"); + .HasColumnType("TEXT"); b.Property("Name") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.Property("ParentCategoryCategoryId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.HasKey("CategoryId"); @@ -119,14 +114,13 @@ namespace DataLayer.Migrations { b.Property("ContributorId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); - b.Property("AudibleAuthorId") - .HasColumnType("nvarchar(max)"); + b.Property("AudibleContributorId") + .HasColumnType("TEXT"); b.Property("Name") - .HasColumnType("nvarchar(450)"); + .HasColumnType("TEXT"); b.HasKey("ContributorId"); @@ -138,10 +132,10 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.LibraryBook", b => { b.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("DateAdded") - .HasColumnType("datetime2"); + .HasColumnType("TEXT"); b.HasKey("BookId"); @@ -152,14 +146,13 @@ namespace DataLayer.Migrations { b.Property("SeriesId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b.Property("AudibleSeriesId") - .HasColumnType("nvarchar(450)"); + .HasColumnType("TEXT"); b.Property("Name") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b.HasKey("SeriesId"); @@ -171,13 +164,13 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.SeriesBook", b => { b.Property("SeriesId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b.Property("Index") - .HasColumnType("real"); + .HasColumnType("REAL"); b.HasKey("SeriesId", "BookId"); @@ -199,18 +192,16 @@ namespace DataLayer.Migrations b.OwnsOne("DataLayer.Rating", "Rating", b1 => { b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b1.Property("OverallRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b1.Property("PerformanceRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b1.Property("StoryRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b1.HasKey("BookId"); @@ -224,14 +215,13 @@ namespace DataLayer.Migrations { b1.Property("SupplementId") .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasColumnType("INTEGER"); b1.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b1.Property("Url") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b1.HasKey("SupplementId"); @@ -246,10 +236,10 @@ namespace DataLayer.Migrations b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => { b1.Property("BookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b1.Property("Tags") - .HasColumnType("nvarchar(max)"); + .HasColumnType("TEXT"); b1.HasKey("BookId"); @@ -261,16 +251,16 @@ namespace DataLayer.Migrations b1.OwnsOne("DataLayer.Rating", "Rating", b2 => { b2.Property("UserDefinedItemBookId") - .HasColumnType("int"); + .HasColumnType("INTEGER"); b2.Property("OverallRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b2.Property("PerformanceRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b2.Property("StoryRating") - .HasColumnType("real"); + .HasColumnType("REAL"); b2.HasKey("UserDefinedItemBookId"); diff --git a/DataLayer/UNTESTED/EfClasses/Book.cs b/DataLayer/UNTESTED/EfClasses/Book.cs index 9c83a9af..40e6492a 100644 --- a/DataLayer/UNTESTED/EfClasses/Book.cs +++ b/DataLayer/UNTESTED/EfClasses/Book.cs @@ -246,5 +246,7 @@ namespace DataLayer context.Entry(this).Reference(s => s.Category).Load(); Category = category; } - } + + public override string ToString() => $"[{AudibleProductId}] {Title}"; + } } diff --git a/DataLayer/UNTESTED/EfClasses/BookContributor.cs b/DataLayer/UNTESTED/EfClasses/BookContributor.cs index 56e5e020..1c9c359a 100644 --- a/DataLayer/UNTESTED/EfClasses/BookContributor.cs +++ b/DataLayer/UNTESTED/EfClasses/BookContributor.cs @@ -23,5 +23,7 @@ namespace DataLayer Role = role; Order = order; } - } + + public override string ToString() => $"{Book} {Contributor} {Role} {Order}"; + } } diff --git a/DataLayer/UNTESTED/EfClasses/Category.cs b/DataLayer/UNTESTED/EfClasses/Category.cs index db8af11c..2ff336fc 100644 --- a/DataLayer/UNTESTED/EfClasses/Category.cs +++ b/DataLayer/UNTESTED/EfClasses/Category.cs @@ -48,5 +48,7 @@ namespace DataLayer if (parentCategory != null) ParentCategory = parentCategory; } - } + + public override string ToString() => $"[{AudibleCategoryId}] {Name}"; + } } diff --git a/DataLayer/UNTESTED/EfClasses/Contributor.cs b/DataLayer/UNTESTED/EfClasses/Contributor.cs index 587f38c6..0c14554a 100644 --- a/DataLayer/UNTESTED/EfClasses/Contributor.cs +++ b/DataLayer/UNTESTED/EfClasses/Contributor.cs @@ -25,6 +25,8 @@ namespace DataLayer private HashSet _booksLink; public IEnumerable BooksLink => _booksLink?.ToList(); + public string AudibleContributorId { get; private set; } + private Contributor() { } public Contributor(string name) { @@ -34,49 +36,13 @@ namespace DataLayer Name = name; } + public Contributor(string name, string audibleContributorId) : this(name) + { + // don't overwrite with null or whitespace but not an error + if (!string.IsNullOrWhiteSpace(audibleContributorId)) + AudibleContributorId = audibleContributorId; + } - public string AudibleAuthorId { get; private set; } - public void UpdateAudibleAuthorId(string authorId) - { - // don't overwrite with null or whitespace but not an error - if (!string.IsNullOrWhiteSpace(authorId)) - AudibleAuthorId = authorId; - } - - #region // AudibleAuthorId refactor: separate author-specific info. overkill for a single optional string - ///// Most authors in Audible have a unique id - //public AudibleAuthorProperty AudibleAuthorProperty { get; private set; } - //public void UpdateAuthorId(string authorId, LibationContext context = null) - //{ - // if (authorId == null) - // return; - // if (AudibleAuthorProperty != null) - // { - // AudibleAuthorProperty.UpdateAudibleAuthorId(authorId); - // return; - // } - // if (context == null) - // throw new ArgumentNullException(nameof(context), "You must provide a context"); - // if (context.Contributors.Find(ContributorId) == null) - // throw new InvalidOperationException("Could not update audible author id."); - // var audibleAuthorProperty = new AudibleAuthorProperty(); - // audibleAuthorProperty.UpdateAudibleAuthorId(authorId); - // context.AuthorProperties.Add(audibleAuthorProperty); - //} - //public class AudibleAuthorProperty - //{ - // public int ContributorId { get; private set; } - // public Contributor Contributor { get; set; } - - // public string AudibleAuthorId { get; private set; } - - // public void UpdateAudibleAuthorId(string authorId) - // { - // if (!string.IsNullOrWhiteSpace(authorId)) - // AudibleAuthorId = authorId; - // } - //} - //// ...and create EF table config - #endregion - } + public override string ToString() => Name; + } } diff --git a/DataLayer/UNTESTED/EfClasses/LibraryBook.cs b/DataLayer/UNTESTED/EfClasses/LibraryBook.cs index 236c5b4d..1796cce3 100644 --- a/DataLayer/UNTESTED/EfClasses/LibraryBook.cs +++ b/DataLayer/UNTESTED/EfClasses/LibraryBook.cs @@ -17,5 +17,7 @@ namespace DataLayer Book = book; DateAdded = dateAdded; } - } + + public override string ToString() => $"{DateAdded:d} {Book}"; + } } diff --git a/DataLayer/UNTESTED/EfClasses/Rating.cs b/DataLayer/UNTESTED/EfClasses/Rating.cs index 40421eba..25ee3e28 100644 --- a/DataLayer/UNTESTED/EfClasses/Rating.cs +++ b/DataLayer/UNTESTED/EfClasses/Rating.cs @@ -72,5 +72,7 @@ namespace DataLayer return string.Join("\r\n", items); } - } + + public override string ToString() => $"Overall={OverallRating} Perf={PerformanceRating} Story={StoryRating}"; + } } diff --git a/DataLayer/UNTESTED/EfClasses/Series.cs b/DataLayer/UNTESTED/EfClasses/Series.cs index 73222f99..6ec79d04 100644 --- a/DataLayer/UNTESTED/EfClasses/Series.cs +++ b/DataLayer/UNTESTED/EfClasses/Series.cs @@ -66,5 +66,7 @@ namespace DataLayer if (_booksLink.SingleOrDefault(sb => sb.Book == book) == null) _booksLink.Add(new SeriesBook(this, book, index)); } - } + + public override string ToString() => Name; + } } diff --git a/DataLayer/UNTESTED/EfClasses/SeriesBook.cs b/DataLayer/UNTESTED/EfClasses/SeriesBook.cs index 907ad0ba..09e23703 100644 --- a/DataLayer/UNTESTED/EfClasses/SeriesBook.cs +++ b/DataLayer/UNTESTED/EfClasses/SeriesBook.cs @@ -34,5 +34,7 @@ namespace DataLayer if (index.HasValue) Index = index.Value; } - } + + public override string ToString() => $"Series={Series} Book={Book}"; + } } diff --git a/DataLayer/UNTESTED/EfClasses/Supplement.cs b/DataLayer/UNTESTED/EfClasses/Supplement.cs index 3965c75f..2207b3f0 100644 --- a/DataLayer/UNTESTED/EfClasses/Supplement.cs +++ b/DataLayer/UNTESTED/EfClasses/Supplement.cs @@ -20,5 +20,7 @@ namespace DataLayer Book = book; Url = url; } - } + + public override string ToString() => $"{Book} {Url.Substring(Url.Length - 4)}"; + } } diff --git a/DataLayer/UNTESTED/EfClasses/UserDefinedItem.cs b/DataLayer/UNTESTED/EfClasses/UserDefinedItem.cs index 244f64b2..5d7234ef 100644 --- a/DataLayer/UNTESTED/EfClasses/UserDefinedItem.cs +++ b/DataLayer/UNTESTED/EfClasses/UserDefinedItem.cs @@ -78,5 +78,7 @@ namespace DataLayer public void UpdateRating(float overallRating, float performanceRating, float storyRating) => Rating.Update(overallRating, performanceRating, storyRating); - } + + public override string ToString() => $"{Book} {Rating} {Tags}"; + } } diff --git a/DtoImporterService/ContributorImporter.cs b/DtoImporterService/ContributorImporter.cs index b0338422..16da65f8 100644 --- a/DtoImporterService/ContributorImporter.cs +++ b/DtoImporterService/ContributorImporter.cs @@ -67,11 +67,9 @@ namespace DtoImporterService var person = context.Contributors.Local.SingleOrDefault(c => c.Name == p.Name); if (person == null) { - person = context.Contributors.Add(new Contributor(p.Name)).Entity; + person = context.Contributors.Add(new Contributor(p.Name, p.Asin)).Entity; qtyNew++; } - - person.UpdateAudibleAuthorId(p.Asin); } return qtyNew; diff --git a/LibationWinForm/UNTESTED/ProductsGrid.cs b/LibationWinForm/UNTESTED/ProductsGrid.cs index 1206fd29..d9a8803f 100644 --- a/LibationWinForm/UNTESTED/ProductsGrid.cs +++ b/LibationWinForm/UNTESTED/ProductsGrid.cs @@ -32,7 +32,7 @@ namespace LibationWinForm public ProductsGrid() { InitializeComponent(); - Disposed += (_, __) => { if (context != null) context.Dispose(); }; + Disposed += (_, __) => context?.Dispose(); } private bool hasBeenDisplayed = false; diff --git a/REFERENCE.txt b/REFERENCE.txt index 3c280e22..69de6dbf 100644 --- a/REFERENCE.txt +++ b/REFERENCE.txt @@ -1,6 +1,7 @@ -- begin VERSIONING --------------------------------------------------------------------------------------------------------------------- https://github.com/rmcrackan/Libation/releases +v3.1-beta.2 : fixed known performance issue: Tag add/edit v3.1-beta.1 : RELEASE TO BETA v3.0.3 : Switch to SQLite. No longer relies on LocalDB, which must be installed separately v3.0.2 : Final using LocalDB @@ -38,19 +39,6 @@ alternate book id (eg BK_RAND_006061) is called 'sku' , 'sku_lite' , 'prod_id' , -- end AUDIBLE DETAILS --------------------------------------------------------------------------------------------------------------------- -- begin SOLUTION LAYOUT --------------------------------------------------------------------------------------------------------------------- -core libraries - extend Standard Libraries - additional simple libraries for general purpose programming -utils: domain ignorant -domain: biz logic - db ignorant - db, domain objects - domain internal utilities: domain aware. db ignorant - domain utilities: domain aware. db aware - incl non-db persistence. unless it needs to be tied into a db intercepter - all user-provided data must be backed up to json -application - do NOT combine jsons for - audible-scraped persistence: library, book details - libation-generated persistence: FilePaths.json @@ -74,31 +62,4 @@ aggregate root is transactional boundary // // test with and without : using TransactionScope scope = new TransactionScope(); //System.Transactions.Transaction.Current.TransactionCompleted += (sender, e) => { }; // also : https://docs.microsoft.com/en-us/dotnet/api/system.transactions.transaction.enlistvolatile - -pattern when using 1 db context per form - public Ctor() - { - InitializeComponent(); - // dispose context here only. DO NOT dispose in OnParentChanged(). parent form will call dispose after this one has been switched. - // disposing context prematurely can result in: - // The ObjectContext instance has been disposed and can no longer be used for operations that require a connection. - this.Disposed += (_, __) => context?.Dispose(); - } -- end EF CORE --------------------------------------------------------------------------------------------------------------------- - --- begin ASYNC/AWAIT --------------------------------------------------------------------------------------------------------------------- -Using Async and Await to update the UI Thread – Stephen Haunts { Coding in the Trenches } -https://stephenhaunts.com/2014/10/14/using-async-and-await-to-update-the-ui-thread/ - -Using Async and Await to update the UI Thread Part 2 – Stephen Haunts { Coding in the Trenches } -https://stephenhaunts.com/2014/10/16/using-async-and-await-to-update-the-ui-thread-part-2/ - -Simple Async Await Example for Asynchronous Programming – Stephen Haunts { Coding in the Trenches } -https://stephenhaunts.com/2014/10/10/simple-async-await-example-for-asynchronous-programming/ - -Async and Await -- Stephen Cleary's famous intro -https://blog.stephencleary.com/2012/02/async-and-await.html - -Async-Await - Best Practices in Asynchronous Programming -- Stephen Cleary -https://msdn.microsoft.com/en-us/magazine/jj991977.aspx --- end ASYNC/AWAIT ---------------------------------------------------------------------------------------------------------------------