From 2f53f2bc6728c541531177b5e1bd00a254e781ba Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 11 Feb 2020 23:51:38 +0100 Subject: [PATCH] Cleaning up the serializer --- Kyoo/ClientApp | 2 +- Kyoo/Controllers/LibraryManager.cs | 1 - Kyoo/DatabaseContext.cs | 8 +++++++- Kyoo/HtmlAPI/JsonSerializer.cs | 8 ++++---- Kyoo/HtmlAPI/ShowsAPI.cs | 1 + Kyoo/Kyoo.csproj | 1 + 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Kyoo/ClientApp b/Kyoo/ClientApp index 1831074c..3d9e34fe 160000 --- a/Kyoo/ClientApp +++ b/Kyoo/ClientApp @@ -1 +1 @@ -Subproject commit 1831074c9d21ccc238409b6c21520780ca666bea +Subproject commit 3d9e34fe7bd7dfe969053412e27776c565bdfcd8 diff --git a/Kyoo/Controllers/LibraryManager.cs b/Kyoo/Controllers/LibraryManager.cs index 2a945cc3..49c91c08 100644 --- a/Kyoo/Controllers/LibraryManager.cs +++ b/Kyoo/Controllers/LibraryManager.cs @@ -67,7 +67,6 @@ namespace Kyoo.Controllers public IEnumerable GetShows(string searchQuery) { - // TODO use case insensitive queries. return (from show in _database.Shows from l in _database.CollectionLinks.DefaultIfEmpty() where l.CollectionID == null select show).AsEnumerable().Union( from collection in _database.Collections select collection.AsShow()) diff --git a/Kyoo/DatabaseContext.cs b/Kyoo/DatabaseContext.cs index 2758d758..a3a1973e 100644 --- a/Kyoo/DatabaseContext.cs +++ b/Kyoo/DatabaseContext.cs @@ -52,7 +52,13 @@ namespace Kyoo modelBuilder.Entity() .Property(t => t.IsForced) .ValueGeneratedNever(); - + + modelBuilder.Entity().Property(x => x.Title).HasColumnType("TEXT COLLATE NOCASE"); + modelBuilder.Entity().Property(x => x.Name).HasColumnType("TEXT COLLATE NOCASE"); + modelBuilder.Entity().Property(x => x.Title).HasColumnType("TEXT COLLATE NOCASE"); + modelBuilder.Entity().Property(x => x.Name).HasColumnType("TEXT COLLATE NOCASE"); + modelBuilder.Entity().Property(x => x.Name).HasColumnType("TEXT COLLATE NOCASE"); + modelBuilder.Entity().Property(x => x.Name).HasColumnType("TEXT COLLATE NOCASE"); modelBuilder.Entity() .HasKey(x => new {x.ShowID, x.GenreID}); diff --git a/Kyoo/HtmlAPI/JsonSerializer.cs b/Kyoo/HtmlAPI/JsonSerializer.cs index 7218272c..42c035f6 100644 --- a/Kyoo/HtmlAPI/JsonSerializer.cs +++ b/Kyoo/HtmlAPI/JsonSerializer.cs @@ -13,7 +13,7 @@ using Newtonsoft.Json.Serialization; namespace Kyoo.Controllers { - public class JsonPropertySelector : DefaultContractResolver + public class JsonPropertySelector : CamelCasePropertyNamesContractResolver { private readonly Dictionary> _ignored; private readonly Dictionary> _forceSerialize; @@ -21,7 +21,7 @@ namespace Kyoo.Controllers public JsonPropertySelector() { _ignored = new Dictionary>(); - _forceSerialize = new Dictionary>(); + _forceSerialize = new Dictionary>(); } public JsonPropertySelector(Dictionary> ignored, Dictionary> forceSerialize) @@ -77,8 +77,8 @@ namespace Kyoo.Controllers { ContractResolver = new JsonPropertySelector(null, new Dictionary>() { - {typeof(Show), new HashSet {"Genres", "Studio", "People", "Seasons"}}, - {typeof(Episode), new HashSet {"Tracks"}} + {typeof(Show), new HashSet {"genres", "studio", "people", "seasons"}}, + {typeof(Episode), new HashSet {"tracks"}} }) }, context.HttpContext.RequestServices.GetRequiredService>(), diff --git a/Kyoo/HtmlAPI/ShowsAPI.cs b/Kyoo/HtmlAPI/ShowsAPI.cs index 77c87a43..4f62c297 100644 --- a/Kyoo/HtmlAPI/ShowsAPI.cs +++ b/Kyoo/HtmlAPI/ShowsAPI.cs @@ -6,6 +6,7 @@ using Kyoo.Controllers; namespace Kyoo.Api { [Route("api/shows")] + [Route("api/show")] [ApiController] public class ShowsController : ControllerBase { diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 3fedc768..12d127eb 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -19,6 +19,7 @@ +