From b340d4a955ec2a8d9349b7d7530e32aebfdbff05 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 29 Oct 2021 15:42:06 -0400 Subject: [PATCH] Add newest levels category --- ProjectLighthouse/Controllers/SlotsController.cs | 14 ++++++++++++++ ProjectLighthouse/Controllers/UserController.cs | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/ProjectLighthouse/Controllers/SlotsController.cs b/ProjectLighthouse/Controllers/SlotsController.cs index 0d4764db..363b43fa 100644 --- a/ProjectLighthouse/Controllers/SlotsController.cs +++ b/ProjectLighthouse/Controllers/SlotsController.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Threading.Tasks; using LBPUnion.ProjectLighthouse.Serialization; @@ -38,5 +39,18 @@ namespace LBPUnion.ProjectLighthouse.Controllers { return this.Ok(slot.Serialize()); } + + [HttpGet("slots")] + public IActionResult NewestSlots([FromQuery] int pageStart, [FromQuery] int pageSize) { + string response = Enumerable.Aggregate(this.database.Slots + .Include(s => s.Creator) + .Include(s => s.Location) + .OrderBy(s => s.FirstUploaded) + .Skip(pageStart - 1) + .Take(Math.Min(pageSize, 30)) + , string.Empty, (current, slot) => current + slot.Serialize()); + + return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "total", 1)); + } } } \ No newline at end of file diff --git a/ProjectLighthouse/Controllers/UserController.cs b/ProjectLighthouse/Controllers/UserController.cs index 1c69c039..d3cc5794 100644 --- a/ProjectLighthouse/Controllers/UserController.cs +++ b/ProjectLighthouse/Controllers/UserController.cs @@ -28,6 +28,11 @@ namespace LBPUnion.ProjectLighthouse.Controllers { return this.Ok(user.Serialize()); } + [HttpGet("users")] + public async Task GetUserAlt([FromQuery] string u) { + return await GetUser(u); + } + // [HttpPost("user/{username}")] // public async Task CreateUser(string username) { // await new Database().CreateUser(username);