mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-22 21:21:28 +00:00
Add simple api
This commit is contained in:
parent
2fee6c62e1
commit
219e02d6cb
12 changed files with 210 additions and 3 deletions
27
ProjectLighthouse/Controllers/Api/GetSlotEndpoint.cs
Normal file
27
ProjectLighthouse/Controllers/Api/GetSlotEndpoint.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#nullable enable
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Controllers.Api;
|
||||||
|
|
||||||
|
public class GetSlotEndpoint : ApiEndpoint
|
||||||
|
{
|
||||||
|
private readonly Database database;
|
||||||
|
|
||||||
|
public GetSlotEndpoint(Database database)
|
||||||
|
{
|
||||||
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("slot/{id:int}")]
|
||||||
|
public async Task<IActionResult> OnGet(int id)
|
||||||
|
{
|
||||||
|
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(u => u.SlotId == id);
|
||||||
|
if (slot == null) return this.NotFound();
|
||||||
|
|
||||||
|
return this.Ok(slot);
|
||||||
|
}
|
||||||
|
}
|
32
ProjectLighthouse/Controllers/Api/GetSlotsEndpoint.cs
Normal file
32
ProjectLighthouse/Controllers/Api/GetSlotsEndpoint.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Controllers.Api;
|
||||||
|
|
||||||
|
public class GetSlotsEndpoint : ApiEndpoint
|
||||||
|
{
|
||||||
|
private readonly Database database;
|
||||||
|
|
||||||
|
public GetSlotsEndpoint(Database database)
|
||||||
|
{
|
||||||
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("slots")]
|
||||||
|
public async Task<IActionResult> OnGet([FromQuery] int limit = 20, [FromQuery] int skip = 0)
|
||||||
|
{
|
||||||
|
limit = Math.Min(ServerStatics.PageSize, limit);
|
||||||
|
|
||||||
|
IEnumerable<MinimalSlot> minimalSlots = (await this.database.Slots.OrderByDescending(s => s.FirstUploaded).Skip(skip).Take(limit).ToListAsync()).Select
|
||||||
|
(MinimalSlot.FromSlot);
|
||||||
|
|
||||||
|
return this.Ok(minimalSlots);
|
||||||
|
}
|
||||||
|
}
|
26
ProjectLighthouse/Controllers/Api/GetUserEndpoint.cs
Normal file
26
ProjectLighthouse/Controllers/Api/GetUserEndpoint.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#nullable enable
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Controllers.Api;
|
||||||
|
|
||||||
|
public class GetUserEndpoint : ApiEndpoint
|
||||||
|
{
|
||||||
|
private readonly Database database;
|
||||||
|
|
||||||
|
public GetUserEndpoint(Database database)
|
||||||
|
{
|
||||||
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("user/{id:int}")]
|
||||||
|
public async Task<IActionResult> OnGet(int id)
|
||||||
|
{
|
||||||
|
User? user = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||||
|
if (user == null) return this.NotFound();
|
||||||
|
|
||||||
|
return this.Ok(user);
|
||||||
|
}
|
||||||
|
}
|
24
ProjectLighthouse/Controllers/Api/StatisticsEndpoint.cs
Normal file
24
ProjectLighthouse/Controllers/Api/StatisticsEndpoint.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Api;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Controllers.Api;
|
||||||
|
|
||||||
|
public class StatisticsEndpoint : ApiEndpoint
|
||||||
|
{
|
||||||
|
[HttpGet("statistics")]
|
||||||
|
public async Task<IActionResult> OnGet()
|
||||||
|
=> this.Ok
|
||||||
|
(
|
||||||
|
new StatisticsResponse
|
||||||
|
{
|
||||||
|
Photos = await StatisticsHelper.PhotoCount(),
|
||||||
|
Slots = await StatisticsHelper.SlotCount(),
|
||||||
|
Users = await StatisticsHelper.UserCount(),
|
||||||
|
RecentMatches = await StatisticsHelper.RecentMatches(),
|
||||||
|
TeamPicks = await StatisticsHelper.TeamPickCount(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
|
@ -177,7 +177,7 @@ public class SlotsController : ControllerBase
|
||||||
"hint_start", pageStart + Math.Min(pageSize, ServerSettings.Instance.EntitledSlots)
|
"hint_start", pageStart + Math.Min(pageSize, ServerSettings.Instance.EntitledSlots)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"total", await StatisticsHelper.MMPicksCount()
|
"total", await StatisticsHelper.TeamPickCount()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class StatisticsController : ControllerBase
|
||||||
public async Task<IActionResult> PlanetStats()
|
public async Task<IActionResult> PlanetStats()
|
||||||
{
|
{
|
||||||
int totalSlotCount = await StatisticsHelper.SlotCount();
|
int totalSlotCount = await StatisticsHelper.SlotCount();
|
||||||
int mmPicksCount = await StatisticsHelper.MMPicksCount();
|
int mmPicksCount = await StatisticsHelper.TeamPickCount();
|
||||||
|
|
||||||
return this.Ok
|
return this.Ok
|
||||||
(
|
(
|
||||||
|
|
|
@ -14,7 +14,7 @@ public static class StatisticsHelper
|
||||||
|
|
||||||
public static async Task<int> UserCount() => await database.Users.CountAsync(u => !u.Banned);
|
public static async Task<int> UserCount() => await database.Users.CountAsync(u => !u.Banned);
|
||||||
|
|
||||||
public static async Task<int> MMPicksCount() => await database.Slots.CountAsync(s => s.TeamPick);
|
public static async Task<int> TeamPickCount() => await database.Slots.CountAsync(s => s.TeamPick);
|
||||||
|
|
||||||
public static async Task<int> PhotoCount() => await database.Photos.CountAsync();
|
public static async Task<int> PhotoCount() => await database.Photos.CountAsync();
|
||||||
}
|
}
|
10
ProjectLighthouse/Types/Api/StatisticsResponse.cs
Normal file
10
ProjectLighthouse/Types/Api/StatisticsResponse.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Types.Api;
|
||||||
|
|
||||||
|
public class StatisticsResponse
|
||||||
|
{
|
||||||
|
public int RecentMatches { get; set; }
|
||||||
|
public int Slots { get; set; }
|
||||||
|
public int Users { get; set; }
|
||||||
|
public int TeamPicks { get; set; }
|
||||||
|
public int Photos { get; set; }
|
||||||
|
}
|
9
ProjectLighthouse/Types/ApiEndpoint.cs
Normal file
9
ProjectLighthouse/Types/ApiEndpoint.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Types;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("/api/v1/")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public class ApiEndpoint : ControllerBase
|
||||||
|
{}
|
26
ProjectLighthouse/Types/Levels/MinimalSlot.cs
Normal file
26
ProjectLighthouse/Types/Levels/MinimalSlot.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
|
|
||||||
|
public struct MinimalSlot
|
||||||
|
{
|
||||||
|
public int SlotId { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string IconHash { get; set; }
|
||||||
|
public bool TeamPick { get; set; }
|
||||||
|
public GameVersion GameVersion { get; set; }
|
||||||
|
#if DEBUG
|
||||||
|
public long FirstUploaded { get; set; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public static MinimalSlot FromSlot(Slot slot)
|
||||||
|
=> new()
|
||||||
|
{
|
||||||
|
SlotId = slot.SlotId,
|
||||||
|
Name = slot.Name,
|
||||||
|
IconHash = slot.IconHash,
|
||||||
|
TeamPick = slot.TeamPick,
|
||||||
|
GameVersion = slot.GameVersion,
|
||||||
|
#if DEBUG
|
||||||
|
FirstUploaded = slot.FirstUploaded,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Serialization;
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
|
@ -19,6 +20,7 @@ public class Slot
|
||||||
{
|
{
|
||||||
[XmlAttribute("type")]
|
[XmlAttribute("type")]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public string Type { get; set; } = "user";
|
public string Type { get; set; } = "user";
|
||||||
|
|
||||||
[Key]
|
[Key]
|
||||||
|
@ -35,24 +37,29 @@ public class Slot
|
||||||
public string IconHash { get; set; } = "";
|
public string IconHash { get; set; } = "";
|
||||||
|
|
||||||
[XmlElement("rootLevel")]
|
[XmlElement("rootLevel")]
|
||||||
|
[JsonIgnore]
|
||||||
public string RootLevel { get; set; } = "";
|
public string RootLevel { get; set; } = "";
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public string ResourceCollection { get; set; } = "";
|
public string ResourceCollection { get; set; } = "";
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[XmlElement("resource")]
|
[XmlElement("resource")]
|
||||||
|
[JsonIgnore]
|
||||||
public string[] Resources {
|
public string[] Resources {
|
||||||
get => this.ResourceCollection.Split(",");
|
get => this.ResourceCollection.Split(",");
|
||||||
set => this.ResourceCollection = string.Join(',', value);
|
set => this.ResourceCollection = string.Join(',', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int LocationId { get; set; }
|
public int LocationId { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int CreatorId { get; set; }
|
public int CreatorId { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(CreatorId))]
|
[ForeignKey(nameof(CreatorId))]
|
||||||
|
[JsonIgnore]
|
||||||
public User? Creator { get; set; }
|
public User? Creator { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -60,6 +67,7 @@ public class Slot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[XmlElement("location")]
|
[XmlElement("location")]
|
||||||
[ForeignKey(nameof(LocationId))]
|
[ForeignKey(nameof(LocationId))]
|
||||||
|
[JsonIgnore]
|
||||||
public Location? Location { get; set; }
|
public Location? Location { get; set; }
|
||||||
|
|
||||||
[XmlElement("initiallyLocked")]
|
[XmlElement("initiallyLocked")]
|
||||||
|
@ -78,6 +86,7 @@ public class Slot
|
||||||
public string AuthorLabels { get; set; } = "";
|
public string AuthorLabels { get; set; } = "";
|
||||||
|
|
||||||
[XmlElement("background")]
|
[XmlElement("background")]
|
||||||
|
[JsonIgnore]
|
||||||
public string BackgroundHash { get; set; } = "";
|
public string BackgroundHash { get; set; } = "";
|
||||||
|
|
||||||
[XmlElement("minPlayers")]
|
[XmlElement("minPlayers")]
|
||||||
|
@ -103,6 +112,7 @@ public class Slot
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int Hearts {
|
public int Hearts {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -124,42 +134,55 @@ public class Slot
|
||||||
public int PlaysComplete => this.PlaysLBP1Complete + this.PlaysLBP2Complete + this.PlaysLBP3Complete + this.PlaysLBPVitaComplete;
|
public int PlaysComplete => this.PlaysLBP1Complete + this.PlaysLBP2Complete + this.PlaysLBP3Complete + this.PlaysLBPVitaComplete;
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP1 { get; set; }
|
public int PlaysLBP1 { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP1Complete { get; set; }
|
public int PlaysLBP1Complete { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP1Unique { get; set; }
|
public int PlaysLBP1Unique { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP2 { get; set; }
|
public int PlaysLBP2 { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP2Complete { get; set; }
|
public int PlaysLBP2Complete { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP2Unique { get; set; }
|
public int PlaysLBP2Unique { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP3 { get; set; }
|
public int PlaysLBP3 { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP3Complete { get; set; }
|
public int PlaysLBP3Complete { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBP3Unique { get; set; }
|
public int PlaysLBP3Unique { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBPVita { get; set; }
|
public int PlaysLBPVita { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBPVitaComplete { get; set; }
|
public int PlaysLBPVitaComplete { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
public int PlaysLBPVitaUnique { get; set; }
|
public int PlaysLBPVitaUnique { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
[XmlElement("thumbsup")]
|
[XmlElement("thumbsup")]
|
||||||
public int Thumbsup {
|
public int Thumbsup {
|
||||||
get {
|
get {
|
||||||
|
@ -170,6 +193,7 @@ public class Slot
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
[XmlElement("thumbsdown")]
|
[XmlElement("thumbsdown")]
|
||||||
public int Thumbsdown {
|
public int Thumbsdown {
|
||||||
get {
|
get {
|
||||||
|
@ -180,6 +204,7 @@ public class Slot
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonPropertyName("averageRating")]
|
||||||
[XmlElement("averageRating")]
|
[XmlElement("averageRating")]
|
||||||
public double RatingLBP1 {
|
public double RatingLBP1 {
|
||||||
get {
|
get {
|
||||||
|
@ -193,6 +218,7 @@ public class Slot
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
[XmlElement("reviewCount")]
|
[XmlElement("reviewCount")]
|
||||||
public int ReviewCount {
|
public int ReviewCount {
|
||||||
get {
|
get {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Serialization;
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||||
|
@ -13,11 +14,17 @@ public class User
|
||||||
public readonly ClientsConnected ClientsConnected = new();
|
public readonly ClientsConnected ClientsConnected = new();
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
public string IconHash { get; set; }
|
public string IconHash { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public int Game { get; set; }
|
public int Game { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int Lists => 0;
|
public int Lists => 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -26,6 +33,7 @@ public class User
|
||||||
public string Biography { get; set; }
|
public string Biography { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public string WebsiteAvatarHash {
|
public string WebsiteAvatarHash {
|
||||||
get {
|
get {
|
||||||
string avatarHash = this.IconHash;
|
string avatarHash = this.IconHash;
|
||||||
|
@ -40,6 +48,7 @@ public class User
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int Reviews {
|
public int Reviews {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -48,6 +57,7 @@ public class User
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int Comments {
|
public int Comments {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -56,6 +66,7 @@ public class User
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int PhotosByMe {
|
public int PhotosByMe {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -64,6 +75,7 @@ public class User
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int PhotosWithMe {
|
public int PhotosWithMe {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -71,15 +83,18 @@ public class User
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public int LocationId { get; set; }
|
public int LocationId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The location of the profile card on the user's earth
|
/// The location of the profile card on the user's earth
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ForeignKey("LocationId")]
|
[ForeignKey("LocationId")]
|
||||||
|
[JsonIgnore]
|
||||||
public Location Location { get; set; }
|
public Location Location { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int HeartedLevels {
|
public int HeartedLevels {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -88,6 +103,7 @@ public class User
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int HeartedUsers {
|
public int HeartedUsers {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -96,6 +112,7 @@ public class User
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int QueuedLevels {
|
public int QueuedLevels {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -103,10 +120,13 @@ public class User
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public string Pins { get; set; } = "";
|
public string Pins { get; set; } = "";
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public string PlanetHash { get; set; } = "";
|
public string PlanetHash { get; set; } = "";
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public int Hearts {
|
public int Hearts {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -115,8 +135,10 @@ public class User
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool IsAdmin { get; set; } = false;
|
public bool IsAdmin { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool PasswordResetRequired { get; set; }
|
public bool PasswordResetRequired { get; set; }
|
||||||
|
|
||||||
public string YayHash { get; set; } = "";
|
public string YayHash { get; set; } = "";
|
||||||
|
@ -125,6 +147,7 @@ public class User
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public string Status {
|
public string Status {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -139,8 +162,10 @@ public class User
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool Banned { get; set; }
|
public bool Banned { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public string BannedReason { get; set; }
|
public string BannedReason { get; set; }
|
||||||
|
|
||||||
public string Serialize(GameVersion gameVersion = GameVersion.LittleBigPlanet1)
|
public string Serialize(GameVersion gameVersion = GameVersion.LittleBigPlanet1)
|
||||||
|
@ -178,6 +203,7 @@ public class User
|
||||||
/// The number of used slots on the earth
|
/// The number of used slots on the earth
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
public int UsedSlots {
|
public int UsedSlots {
|
||||||
get {
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
@ -194,6 +220,7 @@ public class User
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of slots remaining on the earth
|
/// The number of slots remaining on the earth
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
public int FreeSlots => ServerSettings.Instance.EntitledSlots - this.UsedSlots;
|
public int FreeSlots => ServerSettings.Instance.EntitledSlots - this.UsedSlots;
|
||||||
|
|
||||||
private static readonly string[] slotTypes =
|
private static readonly string[] slotTypes =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue