From fbe1e70c10299fb365062258cf435c24f53c9ffa Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 30 Aug 2022 00:54:06 -0500 Subject: [PATCH] Fix level searches on the website (#455) --- ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs index 72f5dfab..a04ef89f 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs @@ -53,10 +53,12 @@ public class SlotsPage : BaseLayout } this.SearchValue = name.Trim(); + + string trimmedSearch = finalSearch.ToString().Trim(); this.SlotCount = await this.Database.Slots.Include(p => p.Creator) .Where(p => p.Type == SlotType.User && !p.Hidden) - .Where(p => p.Name.Contains(finalSearch.ToString())) + .Where(p => p.Name.Contains(trimmedSearch)) .Where(p => p.Creator != null && (targetAuthor == null || string.Equals(p.Creator.Username.ToLower(), targetAuthor.ToLower()))) .Where(p => p.Creator != null && (!p.SubLevel || p.Creator == this.User)) .Where(p => targetGame == null || p.GameVersion == targetGame) @@ -69,7 +71,7 @@ public class SlotsPage : BaseLayout this.Slots = await this.Database.Slots.Include(p => p.Creator) .Where(p => p.Type == SlotType.User && !p.Hidden) - .Where(p => p.Name.Contains(finalSearch.ToString())) + .Where(p => p.Name.Contains(trimmedSearch)) .Where(p => p.Creator != null && (targetAuthor == null || string.Equals(p.Creator.Username.ToLower(), targetAuthor.ToLower()))) .Where(p => p.Creator != null && (!p.SubLevel || p.Creator == this.User)) .Where(p => p.Creator!.LevelVisibility == PrivacyType.All) // TODO: change check for when user is logged in