From c0cf42a7852effd44d757d75b6f9fabcef31803e Mon Sep 17 00:00:00 2001 From: LumaLivy Date: Mon, 8 Nov 2021 21:14:16 -0500 Subject: [PATCH] Add rating info to s/user/ to show your current rating in the pause menu --- ProjectLighthouse/Controllers/SlotsController.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse/Controllers/SlotsController.cs b/ProjectLighthouse/Controllers/SlotsController.cs index 953ea027..89bdf9e8 100644 --- a/ProjectLighthouse/Controllers/SlotsController.cs +++ b/ProjectLighthouse/Controllers/SlotsController.cs @@ -45,18 +45,27 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("s/user/{id:int}")] public async Task SUser(int id) { + User? user = await this.database.UserFromRequest(this.Request); + if (user == null) return this.StatusCode(403, ""); + Token? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.BadRequest(); GameVersion gameVersion = token.GameVersion; - Slot slot = await this.database.Slots.Where(s => s.GameVersion <= gameVersion) + Slot? slot = await this.database.Slots.Where(s => s.GameVersion <= gameVersion) .Include(s => s.Creator) .Include(s => s.Location) .FirstOrDefaultAsync(s => s.SlotId == id); if (slot == null) return this.NotFound(); + RatedLevel? ratedLevel = await this.database.RatedLevels.FirstOrDefaultAsync(r => r.SlotId == id && r.UserId == user.UserId); + if (ratedLevel != null) { + slot.YourRating = ratedLevel.RatingLBP1; + slot.YourDPadRating = ratedLevel.Rating; + } + return this.Ok(slot.Serialize()); }