From 05ac5c63e1751f4470a520a8f128a3e21d11687b Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sat, 31 Dec 2022 10:16:54 -0700 Subject: [PATCH] Formatting --- Source/ApplicationServices/LibraryCommands.cs | 8 ++-- Source/DataLayer/EfClasses/UserDefinedItem.cs | 2 +- Source/LibationSearchEngine/SearchEngine.cs | 42 +++++++++---------- .../LibationWinForms/GridView/ProductsGrid.cs | 2 - 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/Source/ApplicationServices/LibraryCommands.cs b/Source/ApplicationServices/LibraryCommands.cs index 21123ec5..d67b5332 100644 --- a/Source/ApplicationServices/LibraryCommands.cs +++ b/Source/ApplicationServices/LibraryCommands.cs @@ -419,7 +419,7 @@ namespace ApplicationServices Rating rating = null) => new[] { book }.UpdateUserDefinedItem(tags, bookStatus, pdfStatus, rating); - public static int UpdateUserDefinedItem( + public static int UpdateUserDefinedItem( this IEnumerable books, string tags = null, LiberatedStatus? bookStatus = null, @@ -494,10 +494,10 @@ namespace ApplicationServices foreach (var book in books) { context.Attach(book.UserDefinedItem).State = Microsoft.EntityFrameworkCore.EntityState.Modified; - context.Attach(book.UserDefinedItem.Rating).State = Microsoft.EntityFrameworkCore.EntityState.Modified; - } + context.Attach(book.UserDefinedItem.Rating).State = Microsoft.EntityFrameworkCore.EntityState.Modified; + } - var qtyChanges = context.SaveChanges(); + var qtyChanges = context.SaveChanges(); if (qtyChanges > 0) BookUserDefinedItemCommitted?.Invoke(null, books); diff --git a/Source/DataLayer/EfClasses/UserDefinedItem.cs b/Source/DataLayer/EfClasses/UserDefinedItem.cs index e97387ae..91bf236b 100644 --- a/Source/DataLayer/EfClasses/UserDefinedItem.cs +++ b/Source/DataLayer/EfClasses/UserDefinedItem.cs @@ -97,7 +97,7 @@ namespace DataLayer /// The user's individual book rating public Rating Rating { get; private set; } = new Rating(0, 0, 0); - public void UpdateRating(float overallRating, float performanceRating, float storyRating) + public void UpdateRating(float overallRating, float performanceRating, float storyRating) => Rating.Update(overallRating, performanceRating, storyRating); #endregion diff --git a/Source/LibationSearchEngine/SearchEngine.cs b/Source/LibationSearchEngine/SearchEngine.cs index 52404903..260bf14c 100644 --- a/Source/LibationSearchEngine/SearchEngine.cs +++ b/Source/LibationSearchEngine/SearchEngine.cs @@ -89,9 +89,9 @@ namespace LibationSearchEngine ["Hours"] = lb => (lb.Book.LengthInMinutes / 60).ToLuceneString(), ["ProductRating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(), - ["Rating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(), - ["UserRating"] = lb => userOverallRating(lb.Book), - ["MyRating"] = lb => userOverallRating(lb.Book) + ["Rating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(), + ["UserRating"] = lb => userOverallRating(lb.Book), + ["MyRating"] = lb => userOverallRating(lb.Book) } ); @@ -137,7 +137,7 @@ namespace LibationSearchEngine return authors.Intersect(narrators).Any(); } private static string userOverallRating(Book book) => book.UserDefinedItem.Rating.OverallRating.ToLuceneString(); - private static bool isLiberated(Book book) => book.UserDefinedItem.BookStatus == LiberatedStatus.Liberated; + private static bool isLiberated(Book book) => book.UserDefinedItem.BookStatus == LiberatedStatus.Liberated; private static bool liberatedError(Book book) => book.UserDefinedItem.BookStatus == LiberatedStatus.Error; // use these common fields in the "all" default search field @@ -289,25 +289,25 @@ namespace LibationSearchEngine d.AddBool("LiberatedError", v2); }); - public void UpdateUserRatings(Book book) - => updateDocument( - book.AudibleProductId, - d => - { - // - // TODO: better synonym handling. This is too easy to mess up - // + public void UpdateUserRatings(Book book) + => updateDocument( + book.AudibleProductId, + d => + { + // + // TODO: better synonym handling. This is too easy to mess up + // - // fields are key value pairs. MULTIPLE FIELDS CAN POTENTIALLY HAVE THE SAME KEY. - // ie: must remove old before adding new else will create unwanted duplicates. - var v1 = userOverallRating(book); - d.RemoveField("UserRating"); - d.AddNotAnalyzed("UserRating", v1); - d.RemoveField("MyRating"); - d.AddNotAnalyzed("MyRating", v1); - }); + // fields are key value pairs. MULTIPLE FIELDS CAN POTENTIALLY HAVE THE SAME KEY. + // ie: must remove old before adding new else will create unwanted duplicates. + var v1 = userOverallRating(book); + d.RemoveField("UserRating"); + d.AddNotAnalyzed("UserRating", v1); + d.RemoveField("MyRating"); + d.AddNotAnalyzed("MyRating", v1); + }); - private static void updateDocument(string productId, Action action) + private static void updateDocument(string productId, Action action) { var productTerm = new Term(_ID_, productId); diff --git a/Source/LibationWinForms/GridView/ProductsGrid.cs b/Source/LibationWinForms/GridView/ProductsGrid.cs index 90093f27..33a4d88d 100644 --- a/Source/LibationWinForms/GridView/ProductsGrid.cs +++ b/Source/LibationWinForms/GridView/ProductsGrid.cs @@ -51,8 +51,6 @@ namespace LibationWinForms.GridView propertyInfo.SetValue(gridEntryDataGridView, true, null); } - - #region Button controls private void DataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) {