Refactor Database class (#616)

Refactor Database into DatabaseContext
Moved into separate folder so it actually has a namespace instead sitting in the root
This commit is contained in:
Josh 2023-02-15 23:54:30 -06:00 committed by GitHub
parent 2aff26f83d
commit 64b95e807d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
246 changed files with 1211 additions and 965 deletions

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.API.Responses; using LBPUnion.ProjectLighthouse.Servers.API.Responses;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -12,9 +13,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers;
/// </summary> /// </summary>
public class SlotEndpoints : ApiEndpointController public class SlotEndpoints : ApiEndpointController
{ {
private readonly Database database; private readonly DatabaseContext database;
public SlotEndpoints(Database database) public SlotEndpoints(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.API.Responses; using LBPUnion.ProjectLighthouse.Servers.API.Responses;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers;
public class StatisticsEndpoints : ApiEndpointController public class StatisticsEndpoints : ApiEndpointController
{ {
private readonly Database database; private readonly DatabaseContext database;
public StatisticsEndpoints(Database database) public StatisticsEndpoints(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers;
/// </summary> /// </summary>
public class UserEndpoints : ApiEndpointController public class UserEndpoints : ApiEndpointController
{ {
private readonly Database database; private readonly DatabaseContext database;
public UserEndpoints(Database database) public UserEndpoints(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Middlewares;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
@ -25,7 +26,7 @@ public class ApiStartup
} }
); );
services.AddDbContext<Database>(); services.AddDbContext<DatabaseContext>();
services.AddSwaggerGen services.AddSwaggerGen
( (

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/plain")] [Produces("text/plain")]
public class ClientConfigurationController : ControllerBase public class ClientConfigurationController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public ClientConfigurationController(Database database) public ClientConfigurationController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
@ -18,8 +19,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/xml")] [Produces("text/xml")]
public class CommentController : ControllerBase public class CommentController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public CommentController(Database database) public CommentController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
@ -18,9 +19,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Route("LITTLEBIGPLANETPS3_XML/")] [Route("LITTLEBIGPLANETPS3_XML/")]
public class FriendsController : ControllerBase public class FriendsController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public FriendsController(Database database) public FriendsController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System.Net; using System.Net;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
@ -19,9 +20,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/xml")] [Produces("text/xml")]
public class LoginController : ControllerBase public class LoginController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public LoginController(Database database) public LoginController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -14,9 +15,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
public class LogoutController : ControllerBase public class LogoutController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public LogoutController(Database database) public LogoutController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
[Produces("text/xml")] [Produces("text/xml")]
public class EnterLevelController : ControllerBase public class EnterLevelController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public EnterLevelController(Database database) public EnterLevelController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System.Text.Json; using System.Text.Json;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
@ -21,9 +22,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
[Produces("text/xml")] [Produces("text/xml")]
public class MatchController : ControllerBase public class MatchController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public MatchController(Database database) public MatchController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
@ -18,7 +19,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/plain")] [Produces("text/plain")]
public class MessageController : ControllerBase public class MessageController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
private const string license = @" private const string license = @"
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@ -34,7 +35,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>."; along with this program. If not, see <https://www.gnu.org/licenses/>.";
public MessageController(Database database) public MessageController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System.Text.Json; using System.Text.Json;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/xml")] [Produces("text/xml")]
public class ReportController : ControllerBase public class ReportController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public ReportController(Database database) public ReportController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using Discord; using Discord;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
@ -23,9 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Resources;
[Produces("text/xml")] [Produces("text/xml")]
public class PhotosController : ControllerBase public class PhotosController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public PhotosController(Database database) public PhotosController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
@ -21,9 +22,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")] [Produces("text/xml")]
public class CollectionController : ControllerBase public class CollectionController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public CollectionController(Database database) public CollectionController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/plain")] [Produces("text/plain")]
public class LevelTagsController : ControllerBase public class LevelTagsController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public LevelTagsController(Database database) public LevelTagsController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
@ -20,8 +21,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")] [Produces("text/xml")]
public class ListController : ControllerBase public class ListController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public ListController(Database database) public ListController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
@ -24,9 +25,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")] [Produces("text/xml")]
public class PublishController : ControllerBase public class PublishController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public PublishController(Database database) public PublishController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
@ -18,9 +19,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")] [Produces("text/xml")]
public class ReviewController : ControllerBase public class ReviewController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public ReviewController(Database database) public ReviewController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
@ -22,9 +23,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")] [Produces("text/xml")]
public class ScoreController : ControllerBase public class ScoreController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public ScoreController(Database database) public ScoreController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
@ -16,8 +17,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")] [Produces("text/xml")]
public class SearchController : ControllerBase public class SearchController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public SearchController(Database database) public SearchController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
@ -21,8 +22,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")] [Produces("text/xml")]
public class SlotsController : ControllerBase public class SlotsController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public SlotsController(Database database) public SlotsController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
public class StatisticsController : ControllerBase public class StatisticsController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public StatisticsController(Database database) public StatisticsController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System.Text.Json; using System.Text.Json;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
@ -23,9 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/xml")] [Produces("text/xml")]
public class UserController : ControllerBase public class UserController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public UserController(Database database) public UserController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -10,7 +11,7 @@ public class SetLastContactMiddleware : MiddlewareDBContext
public SetLastContactMiddleware(RequestDelegate next) : base(next) public SetLastContactMiddleware(RequestDelegate next) : base(next)
{ } { }
public override async Task InvokeAsync(HttpContext context, Database database) public override async Task InvokeAsync(HttpContext context, DatabaseContext database)
{ {
#nullable enable #nullable enable
// Log LastContact for LBP1. This is done on LBP2/3/V on a Match request. // Log LastContact for LBP1. This is done on LBP2/3/V on a Match request.

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Middlewares;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
@ -45,7 +46,7 @@ public class GameServerStartup
} }
); );
services.AddDbContext<Database>(); services.AddDbContext<DatabaseContext>();
services.Configure<ForwardedHeadersOptions> services.Configure<ForwardedHeadersOptions>
( (

View file

@ -1,5 +1,6 @@
using System.Security.Claims; using System.Security.Claims;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
public class TokenAuthHandler : AuthenticationHandler<AuthenticationSchemeOptions> public class TokenAuthHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{ {
private readonly Database database; private readonly DatabaseContext database;
private const string cookie = "MM_AUTH"; private const string cookie = "MM_AUTH";
public TokenAuthHandler public TokenAuthHandler
@ -17,7 +18,7 @@ public class TokenAuthHandler : AuthenticationHandler<AuthenticationSchemeOption
IOptionsMonitor<AuthenticationSchemeOptions> options, IOptionsMonitor<AuthenticationSchemeOptions> options,
UrlEncoder encoder, UrlEncoder encoder,
ISystemClock clock, ISystemClock clock,
Database database DatabaseContext database
// I said I don't want any damn vegetables (logs) // I said I don't want any damn vegetables (logs)
) : base(options, new NullLoggerFactory(), encoder, clock) ) : base(options, new NullLoggerFactory(), encoder, clock)
{ {

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -18,7 +19,7 @@ public static class CategoryHelper
Categories.Add(new HeartedCategory()); Categories.Add(new HeartedCategory());
Categories.Add(new LuckyDipCategory()); Categories.Add(new LuckyDipCategory());
using Database database = new(); using DatabaseContext database = new();
foreach (DatabaseCategory category in database.CustomCategories) Categories.Add(new CustomCategory(category)); foreach (DatabaseCategory category in database.CustomCategories) Categories.Add(new CustomCategory(category));
} }
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System.Diagnostics; using System.Diagnostics;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
@ -11,8 +12,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Categories;
public abstract class CategoryWithUser : Category public abstract class CategoryWithUser : Category
{ {
public abstract Slot? GetPreviewSlot(Database database, User user); public abstract Slot? GetPreviewSlot(DatabaseContext database, User user);
public override Slot? GetPreviewSlot(Database database) public override Slot? GetPreviewSlot(DatabaseContext database)
{ {
#if DEBUG #if DEBUG
Logger.Error("tried to get preview slot without user on CategoryWithUser", LogArea.Category); Logger.Error("tried to get preview slot without user on CategoryWithUser", LogArea.Category);
@ -21,8 +22,8 @@ public abstract class CategoryWithUser : Category
return null; return null;
} }
public abstract int GetTotalSlots(Database database, User user); public abstract int GetTotalSlots(DatabaseContext database, User user);
public override int GetTotalSlots(Database database) public override int GetTotalSlots(DatabaseContext database)
{ {
#if DEBUG #if DEBUG
Logger.Error("tried to get total slots without user on CategoryWithUser", LogArea.Category); Logger.Error("tried to get total slots without user on CategoryWithUser", LogArea.Category);
@ -31,8 +32,8 @@ public abstract class CategoryWithUser : Category
return -1; return -1;
} }
public abstract IEnumerable<Slot> GetSlots(Database database, User user, int pageStart, int pageSize); public abstract IEnumerable<Slot> GetSlots(DatabaseContext database, User user, int pageStart, int pageSize);
public override IEnumerable<Slot> GetSlots(Database database, int pageStart, int pageSize) public override IEnumerable<Slot> GetSlots(DatabaseContext database, int pageStart, int pageSize)
{ {
#if DEBUG #if DEBUG
Logger.Error("tried to get slots without user on CategoryWithUser", LogArea.Category); Logger.Error("tried to get slots without user on CategoryWithUser", LogArea.Category);
@ -41,13 +42,13 @@ public abstract class CategoryWithUser : Category
return new List<Slot>(); return new List<Slot>();
} }
public new string Serialize(Database database) public new string Serialize(DatabaseContext database)
{ {
Logger.Error("tried to serialize without user on CategoryWithUser", LogArea.Category); Logger.Error("tried to serialize without user on CategoryWithUser", LogArea.Category);
return string.Empty; return string.Empty;
} }
public string Serialize(Database database, User user) public string Serialize(DatabaseContext database, User user)
{ {
Slot? previewSlot = this.GetPreviewSlot(database, user); Slot? previewSlot = this.GetPreviewSlot(database, user);

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -34,9 +35,9 @@ public class CustomCategory : Category
public sealed override string Description { get; set; } public sealed override string Description { get; set; }
public sealed override string IconHash { get; set; } public sealed override string IconHash { get; set; }
public sealed override string Endpoint { get; set; } public sealed override string Endpoint { get; set; }
public override Slot? GetPreviewSlot(Database database) => database.Slots.FirstOrDefault(s => s.SlotId == this.SlotIds[0]); public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.FirstOrDefault(s => s.SlotId == this.SlotIds[0]);
public override IEnumerable<Slot> GetSlots public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize) (DatabaseContext database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3).Where(s => this.SlotIds.Contains(s.SlotId)); => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3).Where(s => this.SlotIds.Contains(s.SlotId));
public override int GetTotalSlots(Database database) => this.SlotIds.Count; public override int GetTotalSlots(DatabaseContext database) => this.SlotIds.Count;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -14,7 +15,7 @@ public class HeartedCategory : CategoryWithUser
public override string Description { get; set; } = "Content you've hearted"; public override string Description { get; set; } = "Content you've hearted";
public override string IconHash { get; set; } = "g820611"; public override string IconHash { get; set; } = "g820611";
public override string Endpoint { get; set; } = "hearted"; public override string Endpoint { get; set; } = "hearted";
public override Slot? GetPreviewSlot(Database database, User user) // note: developer slots act up in LBP3 when listed here, so I omitted it public override Slot? GetPreviewSlot(DatabaseContext database, User user) // note: developer slots act up in LBP3 when listed here, so I omitted it
=> database.HeartedLevels.Where(h => h.UserId == user.UserId) => database.HeartedLevels.Where(h => h.UserId == user.UserId)
.Where(h => h.Slot.Type == SlotType.User && !h.Slot.Hidden && h.Slot.GameVersion <= GameVersion.LittleBigPlanet3) .Where(h => h.Slot.Type == SlotType.User && !h.Slot.Hidden && h.Slot.GameVersion <= GameVersion.LittleBigPlanet3)
.OrderByDescending(h => h.HeartedLevelId) .OrderByDescending(h => h.HeartedLevelId)
@ -24,7 +25,7 @@ public class HeartedCategory : CategoryWithUser
.ByGameVersion(GameVersion.LittleBigPlanet3, false, false, true) .ByGameVersion(GameVersion.LittleBigPlanet3, false, false, true)
.FirstOrDefault(); .FirstOrDefault();
public override IEnumerable<Slot> GetSlots(Database database, User user, int pageStart, int pageSize) public override IEnumerable<Slot> GetSlots(DatabaseContext database, User user, int pageStart, int pageSize)
=> database.HeartedLevels.Where(h => h.UserId == user.UserId) => database.HeartedLevels.Where(h => h.UserId == user.UserId)
.Where(h => h.Slot.Type == SlotType.User && !h.Slot.Hidden && h.Slot.GameVersion <= GameVersion.LittleBigPlanet3) .Where(h => h.Slot.Type == SlotType.User && !h.Slot.Hidden && h.Slot.GameVersion <= GameVersion.LittleBigPlanet3)
.OrderByDescending(h => h.HeartedLevelId) .OrderByDescending(h => h.HeartedLevelId)
@ -35,5 +36,5 @@ public class HeartedCategory : CategoryWithUser
.Skip(Math.Max(0, pageStart)) .Skip(Math.Max(0, pageStart))
.Take(Math.Min(pageSize, 20)); .Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database, User user) => database.HeartedLevels.Count(h => h.UserId == user.UserId); public override int GetTotalSlots(DatabaseContext database, User user) => database.HeartedLevels.Count(h => h.UserId == user.UserId);
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System.Security.Cryptography; using System.Security.Cryptography;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -13,14 +14,14 @@ public class HighestRatedCategory : Category
public override string Description { get; set; } = "Community Highest Rated content"; public override string Description { get; set; } = "Community Highest Rated content";
public override string IconHash { get; set; } = "g820603"; public override string IconHash { get; set; } = "g820603";
public override string Endpoint { get; set; } = "thumbs"; public override string Endpoint { get; set; } = "thumbs";
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Thumbsup); public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Thumbsup);
public override IEnumerable<Slot> GetSlots public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize) (DatabaseContext database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.AsEnumerable() .AsEnumerable()
.OrderByDescending(s => s.Thumbsup) .OrderByDescending(s => s.Thumbsup)
.ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue)) .ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue))
.Skip(Math.Max(0, pageStart - 1)) .Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20)); .Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User); public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -13,12 +14,12 @@ public class LuckyDipCategory : Category
public override string Description { get; set; } = "Randomized uploaded content"; public override string Description { get; set; } = "Randomized uploaded content";
public override string IconHash { get; set; } = "g820605"; public override string IconHash { get; set; } = "g820605";
public override string Endpoint { get; set; } = "lbp2luckydip"; public override string Endpoint { get; set; } = "lbp2luckydip";
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(_ => EF.Functions.Random()).FirstOrDefault(); public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(_ => EF.Functions.Random()).FirstOrDefault();
public override IEnumerable<Slot> GetSlots public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize) (DatabaseContext database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.OrderByDescending(_ => EF.Functions.Random()) .OrderByDescending(_ => EF.Functions.Random())
.Skip(Math.Max(0, pageStart - 1)) .Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20)); .Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User); public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System.Security.Cryptography; using System.Security.Cryptography;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -13,14 +14,14 @@ public class MostHeartedCategory : Category
public override string Description { get; set; } = "The Most Hearted Content"; public override string Description { get; set; } = "The Most Hearted Content";
public override string IconHash { get; set; } = "g820607"; public override string IconHash { get; set; } = "g820607";
public override string Endpoint { get; set; } = "mostHearted"; public override string Endpoint { get; set; } = "mostHearted";
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Hearts); public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Hearts);
public override IEnumerable<Slot> GetSlots public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize) (DatabaseContext database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.AsEnumerable() .AsEnumerable()
.OrderByDescending(s => s.Hearts) .OrderByDescending(s => s.Hearts)
.ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue)) .ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue))
.Skip(Math.Max(0, pageStart - 1)) .Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20)); .Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User); public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -12,17 +13,17 @@ public class MostPlayedCategory : Category
public override string Description { get; set; } = "The most played content"; public override string Description { get; set; } = "The most played content";
public override string IconHash { get; set; } = "g820608"; public override string IconHash { get; set; } = "g820608";
public override string Endpoint { get; set; } = "mostUniquePlays"; public override string Endpoint { get; set; } = "mostUniquePlays";
public override Slot? GetPreviewSlot(Database database) => database.Slots public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots
.Where(s => s.Type == SlotType.User) .Where(s => s.Type == SlotType.User)
.OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique) .OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique)
.ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3) .ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3)
.FirstOrDefault(); .FirstOrDefault();
public override IEnumerable<Slot> GetSlots public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize) (DatabaseContext database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique) .OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique)
.ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3) .ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3)
.Skip(Math.Max(0, pageStart - 1)) .Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20)); .Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User); public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -12,12 +13,12 @@ public class NewestLevelsCategory : Category
public override string Description { get; set; } = "The most recently published content"; public override string Description { get; set; } = "The most recently published content";
public override string IconHash { get; set; } = "g820623"; public override string IconHash { get; set; } = "g820623";
public override string Endpoint { get; set; } = "newest"; public override string Endpoint { get; set; } = "newest";
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(s => s.FirstUploaded).FirstOrDefault(); public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(s => s.FirstUploaded).FirstOrDefault();
public override IEnumerable<Slot> GetSlots public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize) (DatabaseContext database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.OrderByDescending(s => s.FirstUploaded) .OrderByDescending(s => s.FirstUploaded)
.Skip(Math.Max(0, pageStart - 1)) .Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20)); .Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User); public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -14,7 +15,7 @@ public class QueueCategory : CategoryWithUser
public override string Description { get; set; } = "Your queued content"; public override string Description { get; set; } = "Your queued content";
public override string IconHash { get; set; } = "g820614"; public override string IconHash { get; set; } = "g820614";
public override string Endpoint { get; set; } = "queue"; public override string Endpoint { get; set; } = "queue";
public override Slot? GetPreviewSlot(Database database, User user) public override Slot? GetPreviewSlot(DatabaseContext database, User user)
=> database.QueuedLevels.Where(q => q.UserId == user.UserId) => database.QueuedLevels.Where(q => q.UserId == user.UserId)
.Where(q => q.Slot.Type == SlotType.User && !q.Slot.Hidden && q.Slot.GameVersion <= GameVersion.LittleBigPlanet3) .Where(q => q.Slot.Type == SlotType.User && !q.Slot.Hidden && q.Slot.GameVersion <= GameVersion.LittleBigPlanet3)
.OrderByDescending(q => q.QueuedLevelId) .OrderByDescending(q => q.QueuedLevelId)
@ -24,7 +25,7 @@ public class QueueCategory : CategoryWithUser
.ByGameVersion(GameVersion.LittleBigPlanet3, false, false, true) .ByGameVersion(GameVersion.LittleBigPlanet3, false, false, true)
.FirstOrDefault(); .FirstOrDefault();
public override IEnumerable<Slot> GetSlots(Database database, User user, int pageStart, int pageSize) public override IEnumerable<Slot> GetSlots(DatabaseContext database, User user, int pageStart, int pageSize)
=> database.QueuedLevels.Where(q => q.UserId == user.UserId) => database.QueuedLevels.Where(q => q.UserId == user.UserId)
.Where(q => q.Slot.Type == SlotType.User && !q.Slot.Hidden && q.Slot.GameVersion <= GameVersion.LittleBigPlanet3) .Where(q => q.Slot.Type == SlotType.User && !q.Slot.Hidden && q.Slot.GameVersion <= GameVersion.LittleBigPlanet3)
.OrderByDescending(q => q.QueuedLevelId) .OrderByDescending(q => q.QueuedLevelId)
@ -35,5 +36,5 @@ public class QueueCategory : CategoryWithUser
.Skip(Math.Max(0, pageStart - 1)) .Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20)); .Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database, User user) => database.QueuedLevels.Count(q => q.UserId == user.UserId); public override int GetTotalSlots(DatabaseContext database, User user) => database.QueuedLevels.Count(q => q.UserId == user.UserId);
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -12,13 +13,13 @@ public class TeamPicksCategory : Category
public override string Description { get; set; } = "Community Team Picks"; public override string Description { get; set; } = "Community Team Picks";
public override string IconHash { get; set; } = "g820626"; public override string IconHash { get; set; } = "g820626";
public override string Endpoint { get; set; } = "team_picks"; public override string Endpoint { get; set; } = "team_picks";
public override Slot? GetPreviewSlot(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault(s => s.TeamPick); public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault(s => s.TeamPick);
public override IEnumerable<Slot> GetSlots public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize) (DatabaseContext database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.OrderByDescending(s => s.FirstUploaded) .OrderByDescending(s => s.FirstUploaded)
.Where(s => s.TeamPick) .Where(s => s.TeamPick)
.Skip(Math.Max(0, pageStart - 1)) .Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20)); .Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.TeamPick); public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.TeamPick);
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin; namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
@ -7,9 +8,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
[Route("/admin")] [Route("/admin")]
public class AdminPanelController : ControllerBase public class AdminPanelController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public AdminPanelController(Database database) public AdminPanelController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
[Route("/moderation/report/{id:int}")] [Route("/moderation/report/{id:int}")]
public class AdminReportController : ControllerBase public class AdminReportController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public AdminReportController(Database database) public AdminReportController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -15,9 +16,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
[Route("moderation/user/{id:int}")] [Route("moderation/user/{id:int}")]
public class AdminUserController : ControllerBase public class AdminUserController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public AdminUserController(Database database) public AdminUserController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -9,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Debug;
[Route("debug/roomVisualizer")] [Route("debug/roomVisualizer")]
public class RoomVisualizerController : ControllerBase public class RoomVisualizerController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public RoomVisualizerController(Database database) public RoomVisualizerController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.ExternalAuth;
[Route("/authentication")] [Route("/authentication")]
public class AuthenticationController : ControllerBase public class AuthenticationController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public AuthenticationController(Database database) public AuthenticationController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,4 @@
using LBPUnion.ProjectLighthouse.Administration; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -10,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator;
[Route("moderation/case/{id:int}")] [Route("moderation/case/{id:int}")]
public class ModerationCaseController : ControllerBase public class ModerationCaseController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public ModerationCaseController(Database database) public ModerationCaseController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -9,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator;
[Route("moderation")] [Route("moderation")]
public class ModerationRemovalController : ControllerBase public class ModerationRemovalController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public ModerationRemovalController(Database database) public ModerationRemovalController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -12,9 +13,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator;
[Route("moderation/slot/{id:int}")] [Route("moderation/slot/{id:int}")]
public class ModerationSlotController : ControllerBase public class ModerationSlotController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public ModerationSlotController(Database database) public ModerationSlotController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
@ -19,9 +20,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
[Route("slot/{id:int}")] [Route("slot/{id:int}")]
public class SlotPageController : ControllerBase public class SlotPageController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public SlotPageController(Database database) public SlotPageController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
[Route("user/{id:int}")] [Route("user/{id:int}")]
public class UserPageController : ControllerBase public class UserPageController : ControllerBase
{ {
private readonly Database database; private readonly DatabaseContext database;
public UserPageController(Database database) public UserPageController(DatabaseContext database)
{ {
this.database = database; this.database = database;
} }

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -11,7 +12,7 @@ public class UserRequiredRedirectMiddleware : MiddlewareDBContext
public UserRequiredRedirectMiddleware(RequestDelegate next) : base(next) public UserRequiredRedirectMiddleware(RequestDelegate next) : base(next)
{ } { }
public override async Task InvokeAsync(HttpContext ctx, Database database) public override async Task InvokeAsync(HttpContext ctx, DatabaseContext database)
{ {
WebToken? token = database.WebTokenFromRequest(ctx.Request); WebToken? token = database.WebTokenFromRequest(ctx.Request);
if (token == null || pathContains(ctx, "/logout")) if (token == null || pathContains(ctx, "/logout"))

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -11,7 +12,7 @@ public class AdminApiKeyPageModel : BaseLayout
public List<ApiKey> ApiKeys = new(); public List<ApiKey> ApiKeys = new();
public int KeyCount; public int KeyCount;
public AdminApiKeyPageModel(Database database) : base(database) public AdminApiKeyPageModel(DatabaseContext database) : base(database)
{ } { }
public async Task<IActionResult> OnGet() public async Task<IActionResult> OnGet()

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Administration.Maintenance; using LBPUnion.ProjectLighthouse.Administration.Maintenance;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
@ -14,7 +15,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin;
public class AdminPanelPage : BaseLayout public class AdminPanelPage : BaseLayout
{ {
public List<ICommand> Commands = MaintenanceHelper.Commands; public List<ICommand> Commands = MaintenanceHelper.Commands;
public AdminPanelPage(Database database) : base(database) public AdminPanelPage(DatabaseContext database) : base(database)
{ } { }
public List<AdminPanelStatistic> Statistics = new(); public List<AdminPanelStatistic> Statistics = new();

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -11,7 +12,7 @@ public class AdminPanelUsersPage : BaseLayout
public int UserCount; public int UserCount;
public List<User> Users = new(); public List<User> Users = new();
public AdminPanelUsersPage(Database database) : base(database) public AdminPanelUsersPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnGet() public async Task<IActionResult> OnGet()

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin;
public class AdminSetGrantedSlotsPage : BaseLayout public class AdminSetGrantedSlotsPage : BaseLayout
{ {
public AdminSetGrantedSlotsPage(Database database) : base(database) public AdminSetGrantedSlotsPage(DatabaseContext database) : base(database)
{} {}
public User? TargetedUser; public User? TargetedUser;

View file

@ -2,6 +2,7 @@
#if DEBUG #if DEBUG
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
#endif #endif
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
public class FilterTestPage : BaseLayout public class FilterTestPage : BaseLayout
{ {
public FilterTestPage(Database database) : base(database) public FilterTestPage(DatabaseContext database) : base(database)
{} {}
public string? FilteredText; public string? FilteredText;

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
#if !DEBUG #if !DEBUG
@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
public class RoomVisualizerPage : BaseLayout public class RoomVisualizerPage : BaseLayout
{ {
public RoomVisualizerPage(Database database) : base(database) public RoomVisualizerPage(DatabaseContext database) : base(database)
{} {}
public IActionResult OnGet() public IActionResult OnGet()

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -5,7 +6,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
public class VersionInfoPage : BaseLayout public class VersionInfoPage : BaseLayout
{ {
public VersionInfoPage(Database database) : base(database) public VersionInfoPage(DatabaseContext database) : base(database)
{} {}
public IActionResult OnGet() => this.Page(); public IActionResult OnGet() => this.Page();
} }

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email;
public class CompleteEmailVerificationPage : BaseLayout public class CompleteEmailVerificationPage : BaseLayout
{ {
public CompleteEmailVerificationPage(Database database) : base(database) public CompleteEmailVerificationPage(DatabaseContext database) : base(database)
{} {}
public string? Error; public string? Error;

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email;
public class SendVerificationEmailPage : BaseLayout public class SendVerificationEmailPage : BaseLayout
{ {
public SendVerificationEmailPage(Database database) : base(database) public SendVerificationEmailPage(DatabaseContext database) : base(database)
{} {}
public bool Success { get; set; } public bool Success { get; set; }

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
@ -13,7 +14,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email;
public class SetEmailForm : BaseLayout public class SetEmailForm : BaseLayout
{ {
public SetEmailForm(Database database) : base(database) public SetEmailForm(DatabaseContext database) : base(database)
{} {}
public string? Error { get; private set; } public string? Error { get; private set; }

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -5,7 +6,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Errors;
public class NotFoundPage : BaseLayout public class NotFoundPage : BaseLayout
{ {
public NotFoundPage(Database database) : base(database) public NotFoundPage(DatabaseContext database) : base(database)
{} {}
public IActionResult OnGet() => this.Page(); public IActionResult OnGet() => this.Page();

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System.Net; using System.Net;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -12,7 +13,7 @@ public class AuthenticationPage : BaseLayout
public List<PlatformLinkAttempt> LinkAttempts = new(); public List<PlatformLinkAttempt> LinkAttempts = new();
public IPAddress? IpAddress; public IPAddress? IpAddress;
public AuthenticationPage(Database database) : base(database) public AuthenticationPage(DatabaseContext database) : base(database)
{} {}
public IActionResult OnGet() public IActionResult OnGet()

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using JetBrains.Annotations; using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
@ -12,7 +13,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages;
public class LandingPage : BaseLayout public class LandingPage : BaseLayout
{ {
public LandingPage(Database database) : base(database) public LandingPage(DatabaseContext database) : base(database)
{} {}
public int PendingAuthAttempts; public int PendingAuthAttempts;

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Localization; using LBPUnion.ProjectLighthouse.Localization;
using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Servers.Website.Types; using LBPUnion.ProjectLighthouse.Servers.Website.Types;
@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
public class BaseLayout : PageModel public class BaseLayout : PageModel
{ {
public readonly Database Database; public readonly DatabaseContext Database;
public readonly List<PageNavigationItem> NavigationItems = new(); public readonly List<PageNavigationItem> NavigationItems = new();
@ -25,7 +26,7 @@ public class BaseLayout : PageModel
public string Title = string.Empty; public string Title = string.Empty;
private User? user; private User? user;
public BaseLayout(Database database) public BaseLayout(DatabaseContext database)
{ {
this.Database = database; this.Database = database;

View file

@ -2,6 +2,7 @@
using System.Web; using System.Web;
using JetBrains.Annotations; using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Localization.StringLists;
@ -17,7 +18,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
public class LoginForm : BaseLayout public class LoginForm : BaseLayout
{ {
public LoginForm(Database database) : base(database) public LoginForm(DatabaseContext database) : base(database)
{} {}
public string? Error { get; private set; } public string? Error { get; private set; }

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -7,7 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
public class LogoutPage : BaseLayout public class LogoutPage : BaseLayout
{ {
public LogoutPage(Database database) : base(database) public LogoutPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnGet() public async Task<IActionResult> OnGet()
{ {

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using JetBrains.Annotations; using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
public class PasswordResetPage : BaseLayout public class PasswordResetPage : BaseLayout
{ {
public PasswordResetPage(Database database) : base(database) public PasswordResetPage(DatabaseContext database) : base(database)
{} {}
public string? Error { get; private set; } public string? Error { get; private set; }

View file

@ -1,5 +1,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -16,7 +17,7 @@ public class PasswordResetRequestForm : BaseLayout
public string? Status { get; private set; } public string? Status { get; private set; }
public PasswordResetRequestForm(Database database) : base(database) public PasswordResetRequestForm(DatabaseContext database) : base(database)
{ } { }
[UsedImplicitly] [UsedImplicitly]

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -7,7 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
public class PasswordResetRequiredPage : BaseLayout public class PasswordResetRequiredPage : BaseLayout
{ {
public PasswordResetRequiredPage(Database database) : base(database) public PasswordResetRequiredPage(DatabaseContext database) : base(database)
{} {}
public bool WasResetRequest { get; private set; } public bool WasResetRequest { get; private set; }

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -6,7 +7,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
public class PirateSignupPage : BaseLayout public class PirateSignupPage : BaseLayout
{ {
public PirateSignupPage(Database database) : base(database) public PirateSignupPage(DatabaseContext database) : base(database)
{} {}
public IActionResult OnGet() public IActionResult OnGet()

View file

@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using JetBrains.Annotations; using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Localization.StringLists;
@ -14,7 +15,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
public class RegisterForm : BaseLayout public class RegisterForm : BaseLayout
{ {
public RegisterForm(Database database) : base(database) public RegisterForm(DatabaseContext database) : base(database)
{ } { }
public string? Error { get; private set; } public string? Error { get; private set; }

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
public class BannedUsersPage : BaseLayout public class BannedUsersPage : BaseLayout
{ {
public BannedUsersPage(Database database) : base(database) public BannedUsersPage(DatabaseContext database) : base(database)
{} {}
public List<User> Users = new(); public List<User> Users = new();

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
public class CasePage : BaseLayout public class CasePage : BaseLayout
{ {
public CasePage(Database database) : base(database) public CasePage(DatabaseContext database) : base(database)
{} {}
public List<ModerationCase> Cases = new(); public List<ModerationCase> Cases = new();

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
public class HiddenLevelsPage : BaseLayout public class HiddenLevelsPage : BaseLayout
{ {
public HiddenLevelsPage(Database database) : base(database) public HiddenLevelsPage(DatabaseContext database) : base(database)
{} {}
public int PageAmount; public int PageAmount;

View file

@ -1,6 +1,5 @@
@page "/moderation" @page "/moderation"
@using System.Diagnostics @using System.Diagnostics
@using LBPUnion.ProjectLighthouse.Administration
@using LBPUnion.ProjectLighthouse.Extensions @using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.Localization.StringLists @using LBPUnion.ProjectLighthouse.Localization.StringLists
@using LBPUnion.ProjectLighthouse.Servers.Website.Types @using LBPUnion.ProjectLighthouse.Servers.Website.Types

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Servers.Website.Types; using LBPUnion.ProjectLighthouse.Servers.Website.Types;
@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
public class ModPanelPage : BaseLayout public class ModPanelPage : BaseLayout
{ {
public ModPanelPage(Database database) : base(database) public ModPanelPage(DatabaseContext database) : base(database)
{} {}
public List<AdminPanelStatistic> Statistics = new(); public List<AdminPanelStatistic> Statistics = new();

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
public class NewCasePage : BaseLayout public class NewCasePage : BaseLayout
{ {
public NewCasePage(Database database) : base(database) public NewCasePage(DatabaseContext database) : base(database)
{} {}
public CaseType Type { get; set; } public CaseType Type { get; set; }

View file

@ -1,4 +1,5 @@
using System.Text.Json; using System.Text.Json;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
public class ReportPage : BaseLayout public class ReportPage : BaseLayout
{ {
public ReportPage(Database database) : base(database) public ReportPage(DatabaseContext database) : base(database)
{} {}
public GriefReport Report = null!; // Report is not used if it's null in OnGet public GriefReport Report = null!; // Report is not used if it's null in OnGet

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System.Text.Json; using System.Text.Json;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -22,7 +23,7 @@ public class ReportsPage : BaseLayout
public string SearchValue = ""; public string SearchValue = "";
public ReportsPage(Database database) : base(database) public ReportsPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name) public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)

View file

@ -1,4 +1,4 @@
@using LBPUnion.ProjectLighthouse @using LBPUnion.ProjectLighthouse.Database
@using LBPUnion.ProjectLighthouse.Localization @using LBPUnion.ProjectLighthouse.Localization
@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions @using LBPUnion.ProjectLighthouse.Servers.Website.Extensions
@using LBPUnion.ProjectLighthouse.Types.Entities.Level @using LBPUnion.ProjectLighthouse.Types.Entities.Level
@ -25,7 +25,7 @@
{ {
Score score = Model.Scores[i]; Score score = Model.Scores[i];
string[] playerIds = score.PlayerIds; string[] playerIds = score.PlayerIds;
Database database = Model.Database; DatabaseContext database = Model.Database;
<div class="item"> <div class="item">
<span class="ui large text"> <span class="ui large text">
@if(canDelete) @if(canDelete)

View file

@ -1,12 +1,12 @@
@using System.Diagnostics @using System.Diagnostics
@using LBPUnion.ProjectLighthouse @using LBPUnion.ProjectLighthouse.Database
@using LBPUnion.ProjectLighthouse.Types.Entities.Level @using LBPUnion.ProjectLighthouse.Types.Entities.Level
@using LBPUnion.ProjectLighthouse.Types.Entities.Profile @using LBPUnion.ProjectLighthouse.Types.Entities.Profile
@using LBPUnion.ProjectLighthouse.Types.Moderation.Cases @using LBPUnion.ProjectLighthouse.Types.Moderation.Cases
@model LBPUnion.ProjectLighthouse.Types.Entities.Moderation.ModerationCase @model LBPUnion.ProjectLighthouse.Types.Entities.Moderation.ModerationCase
@{ @{
Database database = new(); DatabaseContext database = new();
string color = "blue"; string color = "blue";
string timeZone = (string?)ViewData["TimeZone"] ?? TimeZoneInfo.Local.Id; string timeZone = (string?)ViewData["TimeZone"] ?? TimeZoneInfo.Local.Id;

View file

@ -1,6 +1,6 @@
@using System.Web @using System.Web
@using LBPUnion.ProjectLighthouse
@using LBPUnion.ProjectLighthouse.Configuration @using LBPUnion.ProjectLighthouse.Configuration
@using LBPUnion.ProjectLighthouse.Database
@using LBPUnion.ProjectLighthouse.Localization @using LBPUnion.ProjectLighthouse.Localization
@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions @using LBPUnion.ProjectLighthouse.Servers.Website.Extensions
@using LBPUnion.ProjectLighthouse.Types.Entities.Profile @using LBPUnion.ProjectLighthouse.Types.Entities.Profile
@ -11,7 +11,7 @@
@{ @{
User? user = (User?)ViewData["User"]; User? user = (User?)ViewData["User"];
await using Database database = new(); await using DatabaseContext database = new();
string slotName = HttpUtility.HtmlDecode(string.IsNullOrEmpty(Model!.Name) ? "Unnamed Level" : Model.Name); string slotName = HttpUtility.HtmlDecode(string.IsNullOrEmpty(Model!.Name) ? "Unnamed Level" : Model.Name);

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -19,7 +20,7 @@ public class PhotosPage : BaseLayout
public List<Photo> Photos = new(); public List<Photo> Photos = new();
public string? SearchValue; public string? SearchValue;
public PhotosPage(Database database) : base(database) public PhotosPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name) public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
@ -22,7 +23,7 @@ public class SlotPage : BaseLayout
public readonly bool ReviewsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelReviewsEnabled; public readonly bool ReviewsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelReviewsEnabled;
public Slot? Slot; public Slot? Slot;
public SlotPage(Database database) : base(database) public SlotPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnGet([FromRoute] int id) public async Task<IActionResult> OnGet([FromRoute] int id)

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
@ -12,7 +13,7 @@ public class SlotSettingsPage : BaseLayout
{ {
public Slot? Slot; public Slot? Slot;
public SlotSettingsPage(Database database) : base(database) public SlotSettingsPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnPost([FromRoute] int slotId, [FromForm] string? avatar, [FromForm] string? name, [FromForm] string? description, string? labels) public async Task<IActionResult> OnPost([FromRoute] int slotId, [FromForm] string? avatar, [FromForm] string? name, [FromForm] string? description, string? labels)

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System.Text; using System.Text;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Levels;
@ -23,7 +24,7 @@ public class SlotsPage : BaseLayout
public string? SearchValue; public string? SearchValue;
public SlotsPage(Database database) : base(database) public SlotsPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name) public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor;
public class DisableTwoFactorPage : BaseLayout public class DisableTwoFactorPage : BaseLayout
{ {
public DisableTwoFactorPage(Database database) : base(database) { } public DisableTwoFactorPage(DatabaseContext database) : base(database) { }
public string Error { get; set; } = ""; public string Error { get; set; } = "";

View file

@ -3,6 +3,7 @@ using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Web; using System.Web;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
@ -19,7 +20,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor;
public class SetupTwoFactorPage : BaseLayout public class SetupTwoFactorPage : BaseLayout
{ {
public SetupTwoFactorPage(Database database) : base(database) public SetupTwoFactorPage(DatabaseContext database) : base(database)
{ } { }
public string QrCode { get; set; } = ""; public string QrCode { get; set; } = "";

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor;
public class TwoFactorLoginPage : BaseLayout public class TwoFactorLoginPage : BaseLayout
{ {
public TwoFactorLoginPage(Database database) : base(database) public TwoFactorLoginPage(DatabaseContext database) : base(database)
{ } { }
public string Error { get; set; } = ""; public string Error { get; set; } = "";

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Level;
@ -28,7 +29,7 @@ public class UserPage : BaseLayout
public List<Slot>? QueuedSlots; public List<Slot>? QueuedSlots;
public User? ProfileUser; public User? ProfileUser;
public UserPage(Database database) : base(database) public UserPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnGet([FromRoute] int userId) public async Task<IActionResult> OnGet([FromRoute] int userId)

View file

@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization; using LBPUnion.ProjectLighthouse.Localization;
@ -15,7 +16,7 @@ public class UserSettingsPage : BaseLayout
{ {
public User? ProfileUser; public User? ProfileUser;
public UserSettingsPage(Database database) : base(database) public UserSettingsPage(DatabaseContext database) : base(database)
{} {}
[SuppressMessage("ReSharper", "SpecifyStringComparison")] [SuppressMessage("ReSharper", "SpecifyStringComparison")]

View file

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Users; using LBPUnion.ProjectLighthouse.Types.Users;
@ -20,7 +21,7 @@ public class UsersPage : BaseLayout
public string? SearchValue; public string? SearchValue;
public UsersPage(Database database) : base(database) public UsersPage(DatabaseContext database) : base(database)
{} {}
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name) public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)

View file

@ -1,4 +1,5 @@
using System.Globalization; using System.Globalization;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Localization; using LBPUnion.ProjectLighthouse.Localization;
using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Middlewares;
using LBPUnion.ProjectLighthouse.Servers.Website.Middlewares; using LBPUnion.ProjectLighthouse.Servers.Website.Middlewares;
@ -40,7 +41,7 @@ public class WebsiteStartup
services.AddRazorPages().WithRazorPagesAtContentRoot(); services.AddRazorPages().WithRazorPagesAtContentRoot();
#endif #endif
services.AddDbContext<Database>(); services.AddDbContext<DatabaseContext>();
services.Configure<ForwardedHeadersOptions> services.Configure<ForwardedHeadersOptions>
( (

View file

@ -1,6 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Tests;
@ -14,7 +14,7 @@ public class DatabaseTests : LighthouseServerTest<GameServerTestStartup>
[DatabaseFact] [DatabaseFact]
public async Task CanCreateUserTwice() public async Task CanCreateUserTwice()
{ {
await using Database database = new(); await using DatabaseContext database = new();
int rand = new Random().Next(); int rand = new Random().Next();
User userA = await database.CreateUser("unitTestUser" + rand, CryptoHelper.GenerateAuthToken()); User userA = await database.CreateUser("unitTestUser" + rand, CryptoHelper.GenerateAuthToken());

View file

@ -2,7 +2,7 @@
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Tests;
@ -86,7 +86,7 @@ public class LoginTests : LighthouseServerTest<GameServerTestStartup>
{ {
string username = await this.CreateRandomUser(); string username = await this.CreateRandomUser();
ulong userId = (ulong)Convert.ToInt32(username["unitTestUser".Length..]); ulong userId = (ulong)Convert.ToInt32(username["unitTestUser".Length..]);
await using Database database = new(); await using DatabaseContext database = new();
User user = await database.Users.FirstAsync(u => u.Username == username); User user = await database.Users.FirstAsync(u => u.Username == username);
user.PermissionLevel = PermissionLevel.Banned; user.PermissionLevel = PermissionLevel.Banned;
await database.SaveChangesAsync(); await database.SaveChangesAsync();

View file

@ -2,7 +2,7 @@ using System;
using System.Net.Http; using System.Net.Http;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Tests;
@ -47,7 +47,7 @@ public class MatchTests : LighthouseServerTest<GameServerTestStartup>
await semaphore.WaitAsync(); await semaphore.WaitAsync();
await using Database database = new(); await using DatabaseContext database = new();
int oldPlayerCount = await StatisticsHelper.RecentMatches(database); int oldPlayerCount = await StatisticsHelper.RecentMatches(database);

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Tests;
@ -18,7 +18,7 @@ public class SlotTests : LighthouseServerTest<GameServerTestStartup>
[DatabaseFact] [DatabaseFact]
public async Task ShouldOnlyShowUsersLevels() public async Task ShouldOnlyShowUsersLevels()
{ {
await using Database database = new(); await using DatabaseContext database = new();
Random r = new(); Random r = new();

View file

@ -1,6 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Tests;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -18,7 +18,7 @@ public class AdminTests : LighthouseWebTest
[DatabaseFact] [DatabaseFact]
public async Task ShouldShowAdminPanelButtonWhenAdmin() public async Task ShouldShowAdminPanelButtonWhenAdmin()
{ {
await using Database database = new(); await using DatabaseContext database = new();
Random random = new(); Random random = new();
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure")); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure"));
@ -44,7 +44,7 @@ public class AdminTests : LighthouseWebTest
[DatabaseFact] [DatabaseFact]
public async Task ShouldNotShowAdminPanelButtonWhenNotAdmin() public async Task ShouldNotShowAdminPanelButtonWhenNotAdmin()
{ {
await using Database database = new(); await using DatabaseContext database = new();
Random random = new(); Random random = new();
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure")); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure"));

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Tests;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -17,7 +17,7 @@ public class AuthenticationTests : LighthouseWebTest
[DatabaseFact] [DatabaseFact]
public async Task ShouldLoginWithPassword() public async Task ShouldLoginWithPassword()
{ {
await using Database database = new(); await using DatabaseContext database = new();
Random random = new(); Random random = new();
string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray());
@ -39,7 +39,7 @@ public class AuthenticationTests : LighthouseWebTest
[DatabaseFact] [DatabaseFact]
public async Task ShouldNotLoginWithNoPassword() public async Task ShouldNotLoginWithNoPassword()
{ {
await using Database database = new(); await using DatabaseContext database = new();
Random random = new(); Random random = new();
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("just like the hindenberg,")); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("just like the hindenberg,"));
@ -58,7 +58,7 @@ public class AuthenticationTests : LighthouseWebTest
[DatabaseFact] [DatabaseFact]
public async Task ShouldNotLoginWithWrongPassword() public async Task ShouldNotLoginWithWrongPassword()
{ {
await using Database database = new(); await using DatabaseContext database = new();
Random random = new(); Random random = new();
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure")); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure"));
@ -80,7 +80,7 @@ public class AuthenticationTests : LighthouseWebTest
{ {
const string loggedInAsUsernameTextXPath = "/html/body/div/div/div/div/p[1]"; const string loggedInAsUsernameTextXPath = "/html/body/div/div/div/div/p[1]";
await using Database database = new(); await using DatabaseContext database = new();
Random random = new(); Random random = new();
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure")); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure"));

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse; using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Tests;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -16,7 +16,7 @@ public class RegisterTests : LighthouseWebTest
[DatabaseFact] [DatabaseFact]
public async Task ShouldRegister() public async Task ShouldRegister()
{ {
await using Database database = new(); await using DatabaseContext database = new();
string username = ("unitTestUser" + new Random().Next()).Substring(0, 16); string username = ("unitTestUser" + new Random().Next()).Substring(0, 16);
string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray());
@ -41,7 +41,7 @@ public class RegisterTests : LighthouseWebTest
[DatabaseFact] [DatabaseFact]
public async Task ShouldNotRegisterWithMismatchingPasswords() public async Task ShouldNotRegisterWithMismatchingPasswords()
{ {
await using Database database = new(); await using DatabaseContext database = new();
string username = ("unitTestUser" + new Random().Next()).Substring(0, 16); string username = ("unitTestUser" + new Random().Next()).Substring(0, 16);
string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray());
@ -64,7 +64,7 @@ public class RegisterTests : LighthouseWebTest
[DatabaseFact] [DatabaseFact]
public async Task ShouldNotRegisterWithTakenUsername() public async Task ShouldNotRegisterWithTakenUsername()
{ {
await using Database database = new(); await using DatabaseContext database = new();
string username = ("unitTestUser" + new Random().Next())[..16]; string username = ("unitTestUser" + new Random().Next())[..16];
string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray());

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Xunit; using Xunit;
@ -15,7 +16,7 @@ public sealed class DatabaseFactAttribute : FactAttribute
else else
lock (migrateLock) lock (migrateLock)
{ {
using Database database = new(); using DatabaseContext database = new();
database.Database.Migrate(); database.Database.Migrate();
} }
} }

Some files were not shown because too many files have changed in this diff Show more