mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-25 23:18:56 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using RadicadeServer.RecNet.Enums;
|
||||
using RadicadeServer.RecNet.Events;
|
||||
|
||||
namespace RadicadeServer.API.Events
|
||||
{
|
||||
public static class PlayerEventQueries
|
||||
{
|
||||
public static List<PlayerEventDB> Search(IEnumerable<PlayerEventDB> source, string? term, DateTime now)
|
||||
{
|
||||
var results = source
|
||||
.Where(x => x.Accessibility == Accessibility.Public && x.EndTime > now)
|
||||
.OrderByDescending(x => x.StartTime)
|
||||
.ToList();
|
||||
|
||||
var trimmed = (term ?? string.Empty).Trim();
|
||||
if (trimmed.Length == 0)
|
||||
return results;
|
||||
|
||||
return results
|
||||
.Where(x =>
|
||||
x.Name.Contains(trimmed, StringComparison.OrdinalIgnoreCase) ||
|
||||
(x.Description ?? string.Empty).Contains(trimmed, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static List<PlayerEventDB> InRoom(IEnumerable<PlayerEventDB> source, long roomId)
|
||||
{
|
||||
return source
|
||||
.Where(x => x.RoomId == roomId)
|
||||
.OrderByDescending(x => x.StartTime)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user