mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-21 00:32:27 +00:00
Add rating info to s/user/ to show your current rating in the pause menu
This commit is contained in:
parent
8c4969b145
commit
c0cf42a785
1 changed files with 10 additions and 1 deletions
|
@ -45,18 +45,27 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
[HttpGet("s/user/{id:int}")]
|
||||
public async Task<IActionResult> 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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue