mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-24 14:11:29 +00:00
Advanced level searches and visual fixes (#307)
Co-authored-by: Jayden <jvyden@jvyden.xyz>
This commit is contained in:
parent
9d74a4104b
commit
fb6f8a5c83
3 changed files with 35 additions and 3 deletions
|
@ -28,6 +28,10 @@
|
|||
</div>
|
||||
<input type="submit" class="ui blue button">
|
||||
</form>
|
||||
@if (Model.Comments.Count > 0)
|
||||
{
|
||||
<div class="ui divider"></div>
|
||||
}
|
||||
}
|
||||
|
||||
@for(int i = 0; i < Model.Comments.Count; i++)
|
||||
|
|
|
@ -79,8 +79,9 @@
|
|||
{
|
||||
int count = Model.Reviews.Count;
|
||||
<p>There @(count == 1 ? "is" : "are") @count review@(count == 1 ? "" : "s").</p>
|
||||
<div class="ui divider"></div>
|
||||
}
|
||||
<div class="ui divider"></div>
|
||||
|
||||
|
||||
@for(int i = 0; i < Model.Reviews.Count; i++)
|
||||
{
|
||||
|
@ -147,7 +148,7 @@
|
|||
else
|
||||
{
|
||||
{
|
||||
<p>@review.Text</p>
|
||||
<p>@HttpUtility.HtmlDecode(review.Text)</p>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -31,6 +33,27 @@ public class SlotsPage : BaseLayout
|
|||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) name = "";
|
||||
|
||||
string? targetAuthor = null;
|
||||
GameVersion? targetGame = null;
|
||||
StringBuilder finalSearch = new();
|
||||
foreach (string part in name.Split(" "))
|
||||
{
|
||||
if (part.Contains("by:"))
|
||||
{
|
||||
targetAuthor = part.Replace("by:", "");
|
||||
} else if (part.Contains("game:"))
|
||||
{
|
||||
if (part.Contains('1')) targetGame = GameVersion.LittleBigPlanet1;
|
||||
else if (part.Contains('2')) targetGame = GameVersion.LittleBigPlanet2;
|
||||
else if (part.Contains('3')) targetGame = GameVersion.LittleBigPlanet3;
|
||||
else if (part.Contains('v')) targetGame = GameVersion.LittleBigPlanetVita;
|
||||
}
|
||||
else
|
||||
{
|
||||
finalSearch.Append(part);
|
||||
}
|
||||
}
|
||||
|
||||
this.SearchValue = name.Trim();
|
||||
|
||||
this.SlotCount = await this.Database.Slots.CountAsync(p => p.Name.Contains(this.SearchValue));
|
||||
|
@ -41,12 +64,16 @@ public class SlotsPage : BaseLayout
|
|||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/slots/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
|
||||
this.Slots = await this.Database.Slots.Include(p => p.Creator)
|
||||
.Where(p => p.Name.Contains(this.SearchValue))
|
||||
.Where(p => p.Name.Contains(finalSearch.ToString()))
|
||||
.Where(p => p.Creator != null && (targetAuthor == null || string.Equals(p.Creator.Username.ToLower(), targetAuthor.ToLower())))
|
||||
.Where(p => targetGame == null || p.GameVersion == targetGame)
|
||||
.OrderByDescending(p => p.FirstUploaded)
|
||||
.Skip(pageNumber * ServerStatics.PageSize)
|
||||
.Take(ServerStatics.PageSize)
|
||||
.ToListAsync();
|
||||
|
||||
this.SlotCount = this.Slots.Count;
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue