diff --git a/ProjectLighthouse.Servers.API/Controllers/SlotEndpoints.cs b/ProjectLighthouse.Servers.API/Controllers/SlotEndpoints.cs index 1ccfeb34..89265f7b 100644 --- a/ProjectLighthouse.Servers.API/Controllers/SlotEndpoints.cs +++ b/ProjectLighthouse.Servers.API/Controllers/SlotEndpoints.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.API.Responses; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using Microsoft.AspNetCore.Mvc; @@ -12,9 +13,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers; /// public class SlotEndpoints : ApiEndpointController { - private readonly Database database; + private readonly DatabaseContext database; - public SlotEndpoints(Database database) + public SlotEndpoints(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.API/Controllers/StatisticsEndpoints.cs b/ProjectLighthouse.Servers.API/Controllers/StatisticsEndpoints.cs index 7165849e..ab70fd39 100644 --- a/ProjectLighthouse.Servers.API/Controllers/StatisticsEndpoints.cs +++ b/ProjectLighthouse.Servers.API/Controllers/StatisticsEndpoints.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.API.Responses; using LBPUnion.ProjectLighthouse.Types.Users; @@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers; public class StatisticsEndpoints : ApiEndpointController { - private readonly Database database; + private readonly DatabaseContext database; - public StatisticsEndpoints(Database database) + public StatisticsEndpoints(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs b/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs index c9a3e278..a317b9d8 100644 --- a/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs +++ b/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers; /// public class UserEndpoints : ApiEndpointController { - private readonly Database database; + private readonly DatabaseContext database; - public UserEndpoints(Database database) + public UserEndpoints(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.API/Startup/ApiStartup.cs b/ProjectLighthouse.Servers.API/Startup/ApiStartup.cs index c0469ef6..fd42fdc1 100644 --- a/ProjectLighthouse.Servers.API/Startup/ApiStartup.cs +++ b/ProjectLighthouse.Servers.API/Startup/ApiStartup.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Serialization; using Microsoft.OpenApi.Models; @@ -25,7 +26,7 @@ public class ApiStartup } ); - services.AddDbContext(); + services.AddDbContext(); services.AddSwaggerGen ( diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/ClientConfigurationController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/ClientConfigurationController.cs index fac95b30..9db3c8e7 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/ClientConfigurationController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/ClientConfigurationController.cs @@ -1,6 +1,7 @@ #nullable enable using System.Diagnostics.CodeAnalysis; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Servers.GameServer.Types; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; [Produces("text/plain")] public class ClientConfigurationController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public ClientConfigurationController(Database database) + public ClientConfigurationController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs index b6c3e676..1cb9ee79 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; @@ -18,8 +19,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; [Produces("text/xml")] public class CommentController : ControllerBase { - private readonly Database database; - public CommentController(Database database) + private readonly DatabaseContext database; + public CommentController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/FriendsController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/FriendsController.cs index 3ae620f3..50d84c6d 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/FriendsController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/FriendsController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; @@ -18,9 +19,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; [Route("LITTLEBIGPLANETPS3_XML/")] public class FriendsController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public FriendsController(Database database) + public FriendsController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs index ac226955..66a0fdba 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs @@ -1,6 +1,7 @@ #nullable enable using System.Net; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Logging; @@ -19,9 +20,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; [Produces("text/xml")] public class LoginController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public LoginController(Database database) + public LoginController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/LogoutController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/LogoutController.cs index e3a9d310..349d57e3 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/LogoutController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/LogoutController.cs @@ -1,4 +1,5 @@ -using LBPUnion.ProjectLighthouse.Extensions; +using LBPUnion.ProjectLighthouse.Database; +using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -14,9 +15,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; public class LogoutController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public LogoutController(Database database) + public LogoutController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/EnterLevelController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/EnterLevelController.cs index 6698c936..d2923cf9 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/EnterLevelController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/EnterLevelController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; @@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching; [Produces("text/xml")] public class EnterLevelController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public EnterLevelController(Database database) + public EnterLevelController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs index 98578973..7c5733a5 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs @@ -1,5 +1,6 @@ #nullable enable using System.Text.Json; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Logging; @@ -21,9 +22,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching; [Produces("text/xml")] public class MatchController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public MatchController(Database database) + public MatchController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs index 8b289794..75d471ab 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Logging; @@ -18,7 +19,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; [Produces("text/plain")] public class MessageController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; private const string license = @" 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 along with this program. If not, see ."; - public MessageController(Database database) + public MessageController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/ReportController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/ReportController.cs index c8b56b30..6a066e51 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/ReportController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/ReportController.cs @@ -1,6 +1,7 @@ #nullable enable using System.Text.Json; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; @@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; [Produces("text/xml")] public class ReportController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public ReportController(Database database) + public ReportController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs index 02d9cca7..7d122e8b 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs @@ -1,6 +1,7 @@ #nullable enable using Discord; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Helpers; @@ -23,9 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Resources; [Produces("text/xml")] public class PhotosController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public PhotosController(Database database) + public PhotosController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/CollectionController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/CollectionController.cs index 5096721d..ffd68a27 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/CollectionController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/CollectionController.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Serialization; @@ -21,9 +22,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; [Produces("text/xml")] public class CollectionController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public CollectionController(Database database) + public CollectionController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/LevelTagsController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/LevelTagsController.cs index 40ae0d84..2e7b9b47 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/LevelTagsController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/LevelTagsController.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; @@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; [Produces("text/plain")] public class LevelTagsController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public LevelTagsController(Database database) + public LevelTagsController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ListController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ListController.cs index 7ee2ce79..07374cf3 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ListController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ListController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; @@ -20,8 +21,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; [Produces("text/xml")] public class ListController : ControllerBase { - private readonly Database database; - public ListController(Database database) + private readonly DatabaseContext database; + public ListController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs index b7f2752d..fae4a7f7 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Helpers; @@ -24,9 +25,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; [Produces("text/xml")] public class PublishController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public PublishController(Database database) + public PublishController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ReviewController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ReviewController.cs index 4303f695..84eae921 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ReviewController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ReviewController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; @@ -18,9 +19,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; [Produces("text/xml")] public class ReviewController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public ReviewController(Database database) + public ReviewController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs index 91bb0ff4..cd9faed1 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs @@ -1,5 +1,6 @@ #nullable enable using System.Diagnostics.CodeAnalysis; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Logging; @@ -22,9 +23,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; [Produces("text/xml")] public class ScoreController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public ScoreController(Database database) + public ScoreController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/SearchController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/SearchController.cs index 80af2faa..3773f21d 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/SearchController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/SearchController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types.Entities.Level; @@ -16,8 +17,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; [Produces("text/xml")] public class SearchController : ControllerBase { - private readonly Database database; - public SearchController(Database database) + private readonly DatabaseContext database; + public SearchController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/SlotsController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/SlotsController.cs index da23d25b..13084cdc 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/SlotsController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/SlotsController.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; @@ -21,8 +22,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots; [Produces("text/xml")] public class SlotsController : ControllerBase { - private readonly Database database; - public SlotsController(Database database) + private readonly DatabaseContext database; + public SlotsController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/StatisticsController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/StatisticsController.cs index 0c65f3c1..399b36f8 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/StatisticsController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/StatisticsController.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; using Microsoft.AspNetCore.Authorization; @@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; public class StatisticsController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public StatisticsController(Database database) + public StatisticsController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/UserController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/UserController.cs index 60433956..cba70856 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/UserController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/UserController.cs @@ -1,5 +1,6 @@ #nullable enable using System.Text.Json; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Helpers; @@ -23,9 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers; [Produces("text/xml")] public class UserController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public UserController(Database database) + public UserController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.GameServer/Middlewares/SetLastContactMiddleware.cs b/ProjectLighthouse.Servers.GameServer/Middlewares/SetLastContactMiddleware.cs index 3b08710f..a941b9d9 100644 --- a/ProjectLighthouse.Servers.GameServer/Middlewares/SetLastContactMiddleware.cs +++ b/ProjectLighthouse.Servers.GameServer/Middlewares/SetLastContactMiddleware.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -10,7 +11,7 @@ public class SetLastContactMiddleware : MiddlewareDBContext 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 // Log LastContact for LBP1. This is done on LBP2/3/V on a Match request. diff --git a/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs b/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs index 9fd17804..7ded20de 100644 --- a/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs +++ b/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Serialization; @@ -45,7 +46,7 @@ public class GameServerStartup } ); - services.AddDbContext(); + services.AddDbContext(); services.Configure ( diff --git a/ProjectLighthouse.Servers.GameServer/Startup/TokenAuthHandler.cs b/ProjectLighthouse.Servers.GameServer/Startup/TokenAuthHandler.cs index 101fd47f..08be82c1 100644 --- a/ProjectLighthouse.Servers.GameServer/Startup/TokenAuthHandler.cs +++ b/ProjectLighthouse.Servers.GameServer/Startup/TokenAuthHandler.cs @@ -1,5 +1,6 @@ using System.Security.Claims; using System.Text.Encodings.Web; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Token; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.Logging.Abstractions; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; public class TokenAuthHandler : AuthenticationHandler { - private readonly Database database; + private readonly DatabaseContext database; private const string cookie = "MM_AUTH"; public TokenAuthHandler @@ -17,7 +18,7 @@ public class TokenAuthHandler : AuthenticationHandler options, UrlEncoder encoder, ISystemClock clock, - Database database + DatabaseContext database // I said I don't want any damn vegetables (logs) ) : base(options, new NullLoggerFactory(), encoder, clock) { diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/CategoryHelper.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/CategoryHelper.cs index d6ff6681..90080b64 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/CategoryHelper.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/CategoryHelper.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Levels; @@ -18,7 +19,7 @@ public static class CategoryHelper Categories.Add(new HeartedCategory()); Categories.Add(new LuckyDipCategory()); - using Database database = new(); + using DatabaseContext database = new(); foreach (DatabaseCategory category in database.CustomCategories) Categories.Add(new CustomCategory(category)); } } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/CategoryWithUser.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/CategoryWithUser.cs index 9a74f81f..42f8b6f7 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/CategoryWithUser.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/CategoryWithUser.cs @@ -1,5 +1,6 @@ #nullable enable using System.Diagnostics; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types.Entities.Level; @@ -11,8 +12,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Categories; public abstract class CategoryWithUser : Category { - public abstract Slot? GetPreviewSlot(Database database, User user); - public override Slot? GetPreviewSlot(Database database) + public abstract Slot? GetPreviewSlot(DatabaseContext database, User user); + public override Slot? GetPreviewSlot(DatabaseContext database) { #if DEBUG Logger.Error("tried to get preview slot without user on CategoryWithUser", LogArea.Category); @@ -21,8 +22,8 @@ public abstract class CategoryWithUser : Category return null; } - public abstract int GetTotalSlots(Database database, User user); - public override int GetTotalSlots(Database database) + public abstract int GetTotalSlots(DatabaseContext database, User user); + public override int GetTotalSlots(DatabaseContext database) { #if DEBUG Logger.Error("tried to get total slots without user on CategoryWithUser", LogArea.Category); @@ -31,8 +32,8 @@ public abstract class CategoryWithUser : Category return -1; } - public abstract IEnumerable GetSlots(Database database, User user, int pageStart, int pageSize); - public override IEnumerable GetSlots(Database database, int pageStart, int pageSize) + public abstract IEnumerable GetSlots(DatabaseContext database, User user, int pageStart, int pageSize); + public override IEnumerable GetSlots(DatabaseContext database, int pageStart, int pageSize) { #if DEBUG Logger.Error("tried to get slots without user on CategoryWithUser", LogArea.Category); @@ -41,13 +42,13 @@ public abstract class CategoryWithUser : Category return new List(); } - public new string Serialize(Database database) + public new string Serialize(DatabaseContext database) { Logger.Error("tried to serialize without user on CategoryWithUser", LogArea.Category); return string.Empty; } - public string Serialize(Database database, User user) + public string Serialize(DatabaseContext database, User user) { Slot? previewSlot = this.GetPreviewSlot(database, user); diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/CustomCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/CustomCategory.cs index 92300efa..792d36b5 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/CustomCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/CustomCategory.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Levels; @@ -34,9 +35,9 @@ public class CustomCategory : Category public sealed override string Description { get; set; } public sealed override string IconHash { 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 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)); - public override int GetTotalSlots(Database database) => this.SlotIds.Count; + public override int GetTotalSlots(DatabaseContext database) => this.SlotIds.Count; } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/HeartedCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/HeartedCategory.cs index 22d13997..446de506 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/HeartedCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/HeartedCategory.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; 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 IconHash { get; set; } = "g820611"; 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) .Where(h => h.Slot.Type == SlotType.User && !h.Slot.Hidden && h.Slot.GameVersion <= GameVersion.LittleBigPlanet3) .OrderByDescending(h => h.HeartedLevelId) @@ -24,7 +25,7 @@ public class HeartedCategory : CategoryWithUser .ByGameVersion(GameVersion.LittleBigPlanet3, false, false, true) .FirstOrDefault(); - public override IEnumerable GetSlots(Database database, User user, int pageStart, int pageSize) + public override IEnumerable GetSlots(DatabaseContext database, User user, int pageStart, int pageSize) => database.HeartedLevels.Where(h => h.UserId == user.UserId) .Where(h => h.Slot.Type == SlotType.User && !h.Slot.Hidden && h.Slot.GameVersion <= GameVersion.LittleBigPlanet3) .OrderByDescending(h => h.HeartedLevelId) @@ -35,5 +36,5 @@ public class HeartedCategory : CategoryWithUser .Skip(Math.Max(0, pageStart)) .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); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/HighestRatedCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/HighestRatedCategory.cs index 962530c0..e7a48be7 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/HighestRatedCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/HighestRatedCategory.cs @@ -1,5 +1,6 @@ #nullable enable using System.Security.Cryptography; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; 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 IconHash { get; set; } = "g820603"; 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 GetSlots - (Database database, int pageStart, int pageSize) + (DatabaseContext database, int pageStart, int pageSize) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) .AsEnumerable() .OrderByDescending(s => s.Thumbsup) .ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue)) .Skip(Math.Max(0, pageStart - 1)) .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); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/LuckyDipCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/LuckyDipCategory.cs index 69483a50..760c1570 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/LuckyDipCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/LuckyDipCategory.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; 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 IconHash { get; set; } = "g820605"; 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 GetSlots - (Database database, int pageStart, int pageSize) + (DatabaseContext database, int pageStart, int pageSize) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) .OrderByDescending(_ => EF.Functions.Random()) .Skip(Math.Max(0, pageStart - 1)) .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); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/MostHeartedCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/MostHeartedCategory.cs index db4b5cda..fbd55805 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/MostHeartedCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/MostHeartedCategory.cs @@ -1,5 +1,6 @@ #nullable enable using System.Security.Cryptography; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; 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 IconHash { get; set; } = "g820607"; 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 GetSlots - (Database database, int pageStart, int pageSize) + (DatabaseContext database, int pageStart, int pageSize) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) .AsEnumerable() .OrderByDescending(s => s.Hearts) .ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue)) .Skip(Math.Max(0, pageStart - 1)) .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); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/MostPlayedCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/MostPlayedCategory.cs index ffa28e68..74fa4e9e 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/MostPlayedCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/MostPlayedCategory.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; 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 IconHash { get; set; } = "g820608"; 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) .OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique) .ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3) .FirstOrDefault(); public override IEnumerable GetSlots - (Database database, int pageStart, int pageSize) + (DatabaseContext database, int pageStart, int pageSize) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) .OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique) .ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3) .Skip(Math.Max(0, pageStart - 1)) .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); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/NewestLevelsCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/NewestLevelsCategory.cs index 3977f85a..b432db26 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/NewestLevelsCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/NewestLevelsCategory.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; 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 IconHash { get; set; } = "g820623"; 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 GetSlots - (Database database, int pageStart, int pageSize) + (DatabaseContext database, int pageStart, int pageSize) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) .OrderByDescending(s => s.FirstUploaded) .Skip(Math.Max(0, pageStart - 1)) .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); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/QueueCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/QueueCategory.cs index f7e1570c..4a813580 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/QueueCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/QueueCategory.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; 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 IconHash { get; set; } = "g820614"; 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) .Where(q => q.Slot.Type == SlotType.User && !q.Slot.Hidden && q.Slot.GameVersion <= GameVersion.LittleBigPlanet3) .OrderByDescending(q => q.QueuedLevelId) @@ -24,7 +25,7 @@ public class QueueCategory : CategoryWithUser .ByGameVersion(GameVersion.LittleBigPlanet3, false, false, true) .FirstOrDefault(); - public override IEnumerable GetSlots(Database database, User user, int pageStart, int pageSize) + public override IEnumerable GetSlots(DatabaseContext database, User user, int pageStart, int pageSize) => database.QueuedLevels.Where(q => q.UserId == user.UserId) .Where(q => q.Slot.Type == SlotType.User && !q.Slot.Hidden && q.Slot.GameVersion <= GameVersion.LittleBigPlanet3) .OrderByDescending(q => q.QueuedLevelId) @@ -35,5 +36,5 @@ public class QueueCategory : CategoryWithUser .Skip(Math.Max(0, pageStart - 1)) .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); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.GameServer/Types/Categories/TeamPicksCategory.cs b/ProjectLighthouse.Servers.GameServer/Types/Categories/TeamPicksCategory.cs index 13624956..bb8cfb29 100644 --- a/ProjectLighthouse.Servers.GameServer/Types/Categories/TeamPicksCategory.cs +++ b/ProjectLighthouse.Servers.GameServer/Types/Categories/TeamPicksCategory.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Level; 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 IconHash { get; set; } = "g820626"; 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 GetSlots - (Database database, int pageStart, int pageSize) + (DatabaseContext database, int pageStart, int pageSize) => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) .OrderByDescending(s => s.FirstUploaded) .Where(s => s.TeamPick) .Skip(Math.Max(0, pageStart - 1)) .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); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminPanelController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminPanelController.cs index 67f71941..99e0f307 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminPanelController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminPanelController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using Microsoft.AspNetCore.Mvc; namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin; @@ -7,9 +8,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin; [Route("/admin")] public class AdminPanelController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public AdminPanelController(Database database) + public AdminPanelController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminReportController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminReportController.cs index cefea838..deddcfc5 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminReportController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminReportController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin; [Route("/moderation/report/{id:int}")] public class AdminReportController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public AdminReportController(Database database) + public AdminReportController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs index 8e624ef4..a8b95a24 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -15,9 +16,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin; [Route("moderation/user/{id:int}")] public class AdminUserController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public AdminUserController(Database database) + public AdminUserController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs b/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs index ec2e7d50..547e38ca 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Users; using Microsoft.AspNetCore.Mvc; @@ -9,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Debug; [Route("debug/roomVisualizer")] public class RoomVisualizerController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public RoomVisualizerController(Database database) + public RoomVisualizerController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/ExternalAuth/AuthenticationController.cs b/ProjectLighthouse.Servers.Website/Controllers/ExternalAuth/AuthenticationController.cs index 6ab846ee..a8a75caa 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/ExternalAuth/AuthenticationController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/ExternalAuth/AuthenticationController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Users; @@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.ExternalAuth; [Route("/authentication")] public class AuthenticationController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public AuthenticationController(Database database) + public AuthenticationController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationCaseController.cs b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationCaseController.cs index af54fb84..7fe7e3e3 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationCaseController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationCaseController.cs @@ -1,4 +1,4 @@ -using LBPUnion.ProjectLighthouse.Administration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using Microsoft.AspNetCore.Mvc; @@ -10,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator; [Route("moderation/case/{id:int}")] public class ModerationCaseController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public ModerationCaseController(Database database) + public ModerationCaseController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationRemovalController.cs b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationRemovalController.cs index 9a9d10f8..bcb7e485 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationRemovalController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationRemovalController.cs @@ -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 Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -9,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator; [Route("moderation")] public class ModerationRemovalController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public ModerationRemovalController(Database database) + public ModerationRemovalController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationSlotController.cs b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationSlotController.cs index ae98bb43..bf255822 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationSlotController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationSlotController.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -12,9 +13,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator; [Route("moderation/slot/{id:int}")] public class ModerationSlotController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public ModerationSlotController(Database database) + public ModerationSlotController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs b/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs index 2da7311d..329e33b3 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Level; @@ -19,9 +20,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers; [Route("slot/{id:int}")] public class SlotPageController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public SlotPageController(Database database) + public SlotPageController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs b/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs index 76bd0e9f..e2862f9a 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers; [Route("user/{id:int}")] public class UserPageController : ControllerBase { - private readonly Database database; + private readonly DatabaseContext database; - public UserPageController(Database database) + public UserPageController(DatabaseContext database) { this.database = database; } diff --git a/ProjectLighthouse.Servers.Website/Middlewares/UserRequiredRedirectMiddleware.cs b/ProjectLighthouse.Servers.Website/Middlewares/UserRequiredRedirectMiddleware.cs index 9e40e014..6b5ea5fa 100644 --- a/ProjectLighthouse.Servers.Website/Middlewares/UserRequiredRedirectMiddleware.cs +++ b/ProjectLighthouse.Servers.Website/Middlewares/UserRequiredRedirectMiddleware.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -11,7 +12,7 @@ public class UserRequiredRedirectMiddleware : MiddlewareDBContext 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); if (token == null || pathContains(ctx, "/logout")) diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminApiKeyPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminApiKeyPage.cshtml.cs index 8a539e30..c8c7498d 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminApiKeyPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminApiKeyPage.cshtml.cs @@ -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.Token; using Microsoft.AspNetCore.Mvc; @@ -11,7 +12,7 @@ public class AdminApiKeyPageModel : BaseLayout public List ApiKeys = new(); public int KeyCount; - public AdminApiKeyPageModel(Database database) : base(database) + public AdminApiKeyPageModel(DatabaseContext database) : base(database) { } public async Task OnGet() diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelPage.cshtml.cs index 03d928ab..024556a3 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Administration.Maintenance; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; @@ -14,7 +15,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin; public class AdminPanelPage : BaseLayout { public List Commands = MaintenanceHelper.Commands; - public AdminPanelPage(Database database) : base(database) + public AdminPanelPage(DatabaseContext database) : base(database) { } public List Statistics = new(); diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml.cs index 912b54b5..da391679 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using Microsoft.AspNetCore.Mvc; @@ -11,7 +12,7 @@ public class AdminPanelUsersPage : BaseLayout public int UserCount; public List Users = new(); - public AdminPanelUsersPage(Database database) : base(database) + public AdminPanelUsersPage(DatabaseContext database) : base(database) {} public async Task OnGet() diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminSetGrantedSlotsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminSetGrantedSlotsPage.cshtml.cs index aa527f0a..4a5f3f04 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminSetGrantedSlotsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminSetGrantedSlotsPage.cshtml.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using Microsoft.AspNetCore.Mvc; @@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin; public class AdminSetGrantedSlotsPage : BaseLayout { - public AdminSetGrantedSlotsPage(Database database) : base(database) + public AdminSetGrantedSlotsPage(DatabaseContext database) : base(database) {} public User? TargetedUser; diff --git a/ProjectLighthouse.Servers.Website/Pages/Debug/FilterTestPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Debug/FilterTestPage.cshtml.cs index 704c3145..fe61d7e8 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Debug/FilterTestPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Debug/FilterTestPage.cshtml.cs @@ -2,6 +2,7 @@ #if DEBUG using LBPUnion.ProjectLighthouse.Helpers; #endif +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using Microsoft.AspNetCore.Mvc; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug; public class FilterTestPage : BaseLayout { - public FilterTestPage(Database database) : base(database) + public FilterTestPage(DatabaseContext database) : base(database) {} public string? FilteredText; diff --git a/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml.cs index 43d3b83a..68d6eb92 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using Microsoft.AspNetCore.Mvc; #if !DEBUG @@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug; public class RoomVisualizerPage : BaseLayout { - public RoomVisualizerPage(Database database) : base(database) + public RoomVisualizerPage(DatabaseContext database) : base(database) {} public IActionResult OnGet() diff --git a/ProjectLighthouse.Servers.Website/Pages/Debug/VersionInfoPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Debug/VersionInfoPage.cshtml.cs index d7aa1276..db59e69a 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Debug/VersionInfoPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Debug/VersionInfoPage.cshtml.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using Microsoft.AspNetCore.Mvc; @@ -5,7 +6,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug; public class VersionInfoPage : BaseLayout { - public VersionInfoPage(Database database) : base(database) + public VersionInfoPage(DatabaseContext database) : base(database) {} public IActionResult OnGet() => this.Page(); } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/Email/CompleteEmailVerificationPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Email/CompleteEmailVerificationPage.cshtml.cs index 14d491f2..71ba3cbd 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Email/CompleteEmailVerificationPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Email/CompleteEmailVerificationPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email; public class CompleteEmailVerificationPage : BaseLayout { - public CompleteEmailVerificationPage(Database database) : base(database) + public CompleteEmailVerificationPage(DatabaseContext database) : base(database) {} public string? Error; diff --git a/ProjectLighthouse.Servers.Website/Pages/Email/SendVerificationEmailPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Email/SendVerificationEmailPage.cshtml.cs index 6fde17c2..a7f9cad9 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Email/SendVerificationEmailPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Email/SendVerificationEmailPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email; public class SendVerificationEmailPage : BaseLayout { - public SendVerificationEmailPage(Database database) : base(database) + public SendVerificationEmailPage(DatabaseContext database) : base(database) {} public bool Success { get; set; } diff --git a/ProjectLighthouse.Servers.Website/Pages/Email/SetEmailForm.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Email/SetEmailForm.cshtml.cs index 4be45aa0..6e549a33 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Email/SetEmailForm.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Email/SetEmailForm.cshtml.cs @@ -1,6 +1,7 @@ #nullable enable using System.Diagnostics.CodeAnalysis; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; @@ -13,7 +14,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email; public class SetEmailForm : BaseLayout { - public SetEmailForm(Database database) : base(database) + public SetEmailForm(DatabaseContext database) : base(database) {} public string? Error { get; private set; } diff --git a/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs index bd4ca775..9a10f72b 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using Microsoft.AspNetCore.Mvc; @@ -5,7 +6,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Errors; public class NotFoundPage : BaseLayout { - public NotFoundPage(Database database) : base(database) + public NotFoundPage(DatabaseContext database) : base(database) {} public IActionResult OnGet() => this.Page(); diff --git a/ProjectLighthouse.Servers.Website/Pages/ExternalAuth/AuthenticationPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/ExternalAuth/AuthenticationPage.cshtml.cs index 848e36a9..26ba8b2d 100644 --- a/ProjectLighthouse.Servers.Website/Pages/ExternalAuth/AuthenticationPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/ExternalAuth/AuthenticationPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using System.Net; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using Microsoft.AspNetCore.Mvc; @@ -12,7 +13,7 @@ public class AuthenticationPage : BaseLayout public List LinkAttempts = new(); public IPAddress? IpAddress; - public AuthenticationPage(Database database) : base(database) + public AuthenticationPage(DatabaseContext database) : base(database) {} public IActionResult OnGet() diff --git a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs index 3287a35a..08117494 100644 --- a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using JetBrains.Annotations; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Level; @@ -12,7 +13,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages; public class LandingPage : BaseLayout { - public LandingPage(Database database) : base(database) + public LandingPage(DatabaseContext database) : base(database) {} public int PendingAuthAttempts; diff --git a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs index aa5d438f..e803bc1a 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Localization; using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Servers.Website.Types; @@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; public class BaseLayout : PageModel { - public readonly Database Database; + public readonly DatabaseContext Database; public readonly List NavigationItems = new(); @@ -25,7 +26,7 @@ public class BaseLayout : PageModel public string Title = string.Empty; private User? user; - public BaseLayout(Database database) + public BaseLayout(DatabaseContext database) { this.Database = database; diff --git a/ProjectLighthouse.Servers.Website/Pages/Login/LoginForm.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Login/LoginForm.cshtml.cs index c52f5cc2..fec4b543 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Login/LoginForm.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Login/LoginForm.cshtml.cs @@ -2,6 +2,7 @@ using System.Web; using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Localization.StringLists; @@ -17,7 +18,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login; public class LoginForm : BaseLayout { - public LoginForm(Database database) : base(database) + public LoginForm(DatabaseContext database) : base(database) {} public string? Error { get; private set; } diff --git a/ProjectLighthouse.Servers.Website/Pages/Login/LogoutPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Login/LogoutPage.cshtml.cs index 49ca23ab..3972735b 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Login/LogoutPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Login/LogoutPage.cshtml.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Token; using Microsoft.AspNetCore.Mvc; @@ -7,7 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login; public class LogoutPage : BaseLayout { - public LogoutPage(Database database) : base(database) + public LogoutPage(DatabaseContext database) : base(database) {} public async Task OnGet() { diff --git a/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetPage.cshtml.cs index 7231e52f..393c3d6b 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetPage.cshtml.cs @@ -1,6 +1,7 @@ #nullable enable using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login; public class PasswordResetPage : BaseLayout { - public PasswordResetPage(Database database) : base(database) + public PasswordResetPage(DatabaseContext database) : base(database) {} public string? Error { get; private set; } diff --git a/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequestForm.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequestForm.cshtml.cs index 9ec37742..5814b871 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequestForm.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequestForm.cshtml.cs @@ -1,5 +1,6 @@ using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -16,7 +17,7 @@ public class PasswordResetRequestForm : BaseLayout public string? Status { get; private set; } - public PasswordResetRequestForm(Database database) : base(database) + public PasswordResetRequestForm(DatabaseContext database) : base(database) { } [UsedImplicitly] diff --git a/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequiredPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequiredPage.cshtml.cs index d16b46ef..045095e6 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequiredPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequiredPage.cshtml.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using Microsoft.AspNetCore.Mvc; @@ -7,7 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login; public class PasswordResetRequiredPage : BaseLayout { - public PasswordResetRequiredPage(Database database) : base(database) + public PasswordResetRequiredPage(DatabaseContext database) : base(database) {} public bool WasResetRequest { get; private set; } diff --git a/ProjectLighthouse.Servers.Website/Pages/Login/PirateSignupPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Login/PirateSignupPage.cshtml.cs index 5ce9d4b3..bdc175fd 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Login/PirateSignupPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Login/PirateSignupPage.cshtml.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using Microsoft.AspNetCore.Mvc; @@ -6,7 +7,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login; public class PirateSignupPage : BaseLayout { - public PirateSignupPage(Database database) : base(database) + public PirateSignupPage(DatabaseContext database) : base(database) {} public IActionResult OnGet() diff --git a/ProjectLighthouse.Servers.Website/Pages/Login/RegisterForm.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Login/RegisterForm.cshtml.cs index aa44de3e..0977371b 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Login/RegisterForm.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Login/RegisterForm.cshtml.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Localization.StringLists; @@ -14,7 +15,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login; public class RegisterForm : BaseLayout { - public RegisterForm(Database database) : base(database) + public RegisterForm(DatabaseContext database) : base(database) { } public string? Error { get; private set; } diff --git a/ProjectLighthouse.Servers.Website/Pages/Moderation/BannedUsersPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Moderation/BannedUsersPage.cshtml.cs index d38d88a2..eaec543c 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Moderation/BannedUsersPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Moderation/BannedUsersPage.cshtml.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation; public class BannedUsersPage : BaseLayout { - public BannedUsersPage(Database database) : base(database) + public BannedUsersPage(DatabaseContext database) : base(database) {} public List Users = new(); diff --git a/ProjectLighthouse.Servers.Website/Pages/Moderation/CasePage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Moderation/CasePage.cshtml.cs index 2aa35979..7433dd8c 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Moderation/CasePage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Moderation/CasePage.cshtml.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation; public class CasePage : BaseLayout { - public CasePage(Database database) : base(database) + public CasePage(DatabaseContext database) : base(database) {} public List Cases = new(); diff --git a/ProjectLighthouse.Servers.Website/Pages/Moderation/HiddenLevelsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Moderation/HiddenLevelsPage.cshtml.cs index 0814c8cd..ed0f772b 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Moderation/HiddenLevelsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Moderation/HiddenLevelsPage.cshtml.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation; public class HiddenLevelsPage : BaseLayout { - public HiddenLevelsPage(Database database) : base(database) + public HiddenLevelsPage(DatabaseContext database) : base(database) {} public int PageAmount; diff --git a/ProjectLighthouse.Servers.Website/Pages/Moderation/ModPanelPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Moderation/ModPanelPage.cshtml index 9d4de737..00d1851f 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Moderation/ModPanelPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Moderation/ModPanelPage.cshtml @@ -1,6 +1,5 @@ @page "/moderation" @using System.Diagnostics -@using LBPUnion.ProjectLighthouse.Administration @using LBPUnion.ProjectLighthouse.Extensions @using LBPUnion.ProjectLighthouse.Localization.StringLists @using LBPUnion.ProjectLighthouse.Servers.Website.Types diff --git a/ProjectLighthouse.Servers.Website/Pages/Moderation/ModPanelPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Moderation/ModPanelPage.cshtml.cs index 49e8b3af..0ed69c38 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Moderation/ModPanelPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Moderation/ModPanelPage.cshtml.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Types; @@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation; public class ModPanelPage : BaseLayout { - public ModPanelPage(Database database) : base(database) + public ModPanelPage(DatabaseContext database) : base(database) {} public List Statistics = new(); diff --git a/ProjectLighthouse.Servers.Website/Pages/Moderation/NewCasePage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Moderation/NewCasePage.cshtml.cs index 9052a71a..fe365547 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Moderation/NewCasePage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Moderation/NewCasePage.cshtml.cs @@ -1,3 +1,4 @@ +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation; public class NewCasePage : BaseLayout { - public NewCasePage(Database database) : base(database) + public NewCasePage(DatabaseContext database) : base(database) {} public CaseType Type { get; set; } diff --git a/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportPage.cshtml.cs index 5375f7da..8fc751ca 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportPage.cshtml.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation; 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 diff --git a/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportsPage.cshtml.cs index e7717be2..5be1a733 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportsPage.cshtml.cs @@ -1,6 +1,7 @@ #nullable enable using System.Text.Json; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -22,7 +23,7 @@ public class ReportsPage : BaseLayout public string SearchValue = ""; - public ReportsPage(Database database) : base(database) + public ReportsPage(DatabaseContext database) : base(database) {} public async Task OnGet([FromRoute] int pageNumber, [FromQuery] string? name) diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/LeaderboardPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/LeaderboardPartial.cshtml index 03c28d19..e25505e8 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/LeaderboardPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/LeaderboardPartial.cshtml @@ -1,4 +1,4 @@ -@using LBPUnion.ProjectLighthouse +@using LBPUnion.ProjectLighthouse.Database @using LBPUnion.ProjectLighthouse.Localization @using LBPUnion.ProjectLighthouse.Servers.Website.Extensions @using LBPUnion.ProjectLighthouse.Types.Entities.Level @@ -25,7 +25,7 @@ { Score score = Model.Scores[i]; string[] playerIds = score.PlayerIds; - Database database = Model.Database; + DatabaseContext database = Model.Database;
@if(canDelete) diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml index 6bb49868..a5bef705 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml @@ -1,12 +1,12 @@ @using System.Diagnostics -@using LBPUnion.ProjectLighthouse +@using LBPUnion.ProjectLighthouse.Database @using LBPUnion.ProjectLighthouse.Types.Entities.Level @using LBPUnion.ProjectLighthouse.Types.Entities.Profile @using LBPUnion.ProjectLighthouse.Types.Moderation.Cases @model LBPUnion.ProjectLighthouse.Types.Entities.Moderation.ModerationCase @{ - Database database = new(); + DatabaseContext database = new(); string color = "blue"; string timeZone = (string?)ViewData["TimeZone"] ?? TimeZoneInfo.Local.Id; diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml index f7e52aa3..8d3140e2 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml @@ -1,6 +1,6 @@ @using System.Web -@using LBPUnion.ProjectLighthouse @using LBPUnion.ProjectLighthouse.Configuration +@using LBPUnion.ProjectLighthouse.Database @using LBPUnion.ProjectLighthouse.Localization @using LBPUnion.ProjectLighthouse.Servers.Website.Extensions @using LBPUnion.ProjectLighthouse.Types.Entities.Profile @@ -11,7 +11,7 @@ @{ 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); diff --git a/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml.cs index 2914cc2e..6f9504db 100644 --- a/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using Microsoft.AspNetCore.Mvc; @@ -19,7 +20,7 @@ public class PhotosPage : BaseLayout public List Photos = new(); public string? SearchValue; - public PhotosPage(Database database) : base(database) + public PhotosPage(DatabaseContext database) : base(database) {} public async Task OnGet([FromRoute] int pageNumber, [FromQuery] string? name) diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml.cs index c9331196..5072e278 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Level; @@ -22,7 +23,7 @@ public class SlotPage : BaseLayout public readonly bool ReviewsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelReviewsEnabled; public Slot? Slot; - public SlotPage(Database database) : base(database) + public SlotPage(DatabaseContext database) : base(database) {} public async Task OnGet([FromRoute] int id) diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml.cs index 66aa3fdb..8d9e5ffe 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; @@ -12,7 +13,7 @@ public class SlotSettingsPage : BaseLayout { public Slot? Slot; - public SlotSettingsPage(Database database) : base(database) + public SlotSettingsPage(DatabaseContext database) : base(database) {} public async Task OnPost([FromRoute] int slotId, [FromForm] string? avatar, [FromForm] string? name, [FromForm] string? description, string? labels) diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs index 66aac909..2c15fde7 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml.cs @@ -1,6 +1,7 @@ #nullable enable using System.Text; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Levels; @@ -23,7 +24,7 @@ public class SlotsPage : BaseLayout public string? SearchValue; - public SlotsPage(Database database) : base(database) + public SlotsPage(DatabaseContext database) : base(database) {} public async Task OnGet([FromRoute] int pageNumber, [FromQuery] string? name) diff --git a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/DisableTwoFactorPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/DisableTwoFactorPage.cshtml.cs index 4bcf8ff7..4ada6bc1 100644 --- a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/DisableTwoFactorPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/DisableTwoFactorPage.cshtml.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor; public class DisableTwoFactorPage : BaseLayout { - public DisableTwoFactorPage(Database database) : base(database) { } + public DisableTwoFactorPage(DatabaseContext database) : base(database) { } public string Error { get; set; } = ""; diff --git a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/SetupTwoFactorPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/SetupTwoFactorPage.cshtml.cs index b8ede411..ada51264 100644 --- a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/SetupTwoFactorPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/SetupTwoFactorPage.cshtml.cs @@ -3,6 +3,7 @@ using System.Security.Cryptography; using System.Text; using System.Web; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; @@ -19,7 +20,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor; public class SetupTwoFactorPage : BaseLayout { - public SetupTwoFactorPage(Database database) : base(database) + public SetupTwoFactorPage(DatabaseContext database) : base(database) { } public string QrCode { get; set; } = ""; diff --git a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs index 67f8dfea..80674c82 100644 --- a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; @@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor; public class TwoFactorLoginPage : BaseLayout { - public TwoFactorLoginPage(Database database) : base(database) + public TwoFactorLoginPage(DatabaseContext database) : base(database) { } public string Error { get; set; } = ""; diff --git a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml.cs index 5bb18d0e..17cfbb1c 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; using LBPUnion.ProjectLighthouse.Types.Entities.Level; @@ -28,7 +29,7 @@ public class UserPage : BaseLayout public List? QueuedSlots; public User? ProfileUser; - public UserPage(Database database) : base(database) + public UserPage(DatabaseContext database) : base(database) {} public async Task OnGet([FromRoute] int userId) diff --git a/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml.cs index 2067ca1c..99620161 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml.cs @@ -1,6 +1,7 @@ #nullable enable using System.Diagnostics.CodeAnalysis; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Localization; @@ -15,7 +16,7 @@ public class UserSettingsPage : BaseLayout { public User? ProfileUser; - public UserSettingsPage(Database database) : base(database) + public UserSettingsPage(DatabaseContext database) : base(database) {} [SuppressMessage("ReSharper", "SpecifyStringComparison")] diff --git a/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml.cs index 8cafb1f8..f41b9c0b 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml.cs @@ -1,5 +1,6 @@ #nullable enable using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Users; @@ -20,7 +21,7 @@ public class UsersPage : BaseLayout public string? SearchValue; - public UsersPage(Database database) : base(database) + public UsersPage(DatabaseContext database) : base(database) {} public async Task OnGet([FromRoute] int pageNumber, [FromQuery] string? name) diff --git a/ProjectLighthouse.Servers.Website/Startup/WebsiteStartup.cs b/ProjectLighthouse.Servers.Website/Startup/WebsiteStartup.cs index 4ce3b61e..db629433 100644 --- a/ProjectLighthouse.Servers.Website/Startup/WebsiteStartup.cs +++ b/ProjectLighthouse.Servers.Website/Startup/WebsiteStartup.cs @@ -1,4 +1,5 @@ using System.Globalization; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Localization; using LBPUnion.ProjectLighthouse.Middlewares; using LBPUnion.ProjectLighthouse.Servers.Website.Middlewares; @@ -40,7 +41,7 @@ public class WebsiteStartup services.AddRazorPages().WithRazorPagesAtContentRoot(); #endif - services.AddDbContext(); + services.AddDbContext(); services.Configure ( diff --git a/ProjectLighthouse.Tests.GameApiTests/Tests/DatabaseTests.cs b/ProjectLighthouse.Tests.GameApiTests/Tests/DatabaseTests.cs index 6aed84f8..5a7314e7 100644 --- a/ProjectLighthouse.Tests.GameApiTests/Tests/DatabaseTests.cs +++ b/ProjectLighthouse.Tests.GameApiTests/Tests/DatabaseTests.cs @@ -1,6 +1,6 @@ using System; using System.Threading.Tasks; -using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; using LBPUnion.ProjectLighthouse.Tests; @@ -14,7 +14,7 @@ public class DatabaseTests : LighthouseServerTest [DatabaseFact] public async Task CanCreateUserTwice() { - await using Database database = new(); + await using DatabaseContext database = new(); int rand = new Random().Next(); User userA = await database.CreateUser("unitTestUser" + rand, CryptoHelper.GenerateAuthToken()); diff --git a/ProjectLighthouse.Tests.GameApiTests/Tests/LoginTests.cs b/ProjectLighthouse.Tests.GameApiTests/Tests/LoginTests.cs index 323376b6..f0e031f8 100644 --- a/ProjectLighthouse.Tests.GameApiTests/Tests/LoginTests.cs +++ b/ProjectLighthouse.Tests.GameApiTests/Tests/LoginTests.cs @@ -2,7 +2,7 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; -using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; using LBPUnion.ProjectLighthouse.Tests; @@ -86,7 +86,7 @@ public class LoginTests : LighthouseServerTest { string username = await this.CreateRandomUser(); 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.PermissionLevel = PermissionLevel.Banned; await database.SaveChangesAsync(); diff --git a/ProjectLighthouse.Tests.GameApiTests/Tests/MatchTests.cs b/ProjectLighthouse.Tests.GameApiTests/Tests/MatchTests.cs index e4a0fdb5..7312a05e 100644 --- a/ProjectLighthouse.Tests.GameApiTests/Tests/MatchTests.cs +++ b/ProjectLighthouse.Tests.GameApiTests/Tests/MatchTests.cs @@ -2,7 +2,7 @@ using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; using LBPUnion.ProjectLighthouse.Tests; @@ -47,7 +47,7 @@ public class MatchTests : LighthouseServerTest await semaphore.WaitAsync(); - await using Database database = new(); + await using DatabaseContext database = new(); int oldPlayerCount = await StatisticsHelper.RecentMatches(database); diff --git a/ProjectLighthouse.Tests.GameApiTests/Tests/SlotTests.cs b/ProjectLighthouse.Tests.GameApiTests/Tests/SlotTests.cs index 62ced95c..9a81286b 100644 --- a/ProjectLighthouse.Tests.GameApiTests/Tests/SlotTests.cs +++ b/ProjectLighthouse.Tests.GameApiTests/Tests/SlotTests.cs @@ -1,7 +1,7 @@ using System; using System.Net.Http; using System.Threading.Tasks; -using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup; using LBPUnion.ProjectLighthouse.Tests; @@ -18,7 +18,7 @@ public class SlotTests : LighthouseServerTest [DatabaseFact] public async Task ShouldOnlyShowUsersLevels() { - await using Database database = new(); + await using DatabaseContext database = new(); Random r = new(); diff --git a/ProjectLighthouse.Tests.WebsiteTests/Tests/AdminTests.cs b/ProjectLighthouse.Tests.WebsiteTests/Tests/AdminTests.cs index 0a5daa84..3bc33be2 100644 --- a/ProjectLighthouse.Tests.WebsiteTests/Tests/AdminTests.cs +++ b/ProjectLighthouse.Tests.WebsiteTests/Tests/AdminTests.cs @@ -1,6 +1,6 @@ using System; using System.Threading.Tasks; -using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -18,7 +18,7 @@ public class AdminTests : LighthouseWebTest [DatabaseFact] public async Task ShouldShowAdminPanelButtonWhenAdmin() { - await using Database database = new(); + await using DatabaseContext database = new(); Random random = new(); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure")); @@ -44,7 +44,7 @@ public class AdminTests : LighthouseWebTest [DatabaseFact] public async Task ShouldNotShowAdminPanelButtonWhenNotAdmin() { - await using Database database = new(); + await using DatabaseContext database = new(); Random random = new(); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure")); diff --git a/ProjectLighthouse.Tests.WebsiteTests/Tests/AuthenticationTests.cs b/ProjectLighthouse.Tests.WebsiteTests/Tests/AuthenticationTests.cs index cf3eac14..c2332203 100644 --- a/ProjectLighthouse.Tests.WebsiteTests/Tests/AuthenticationTests.cs +++ b/ProjectLighthouse.Tests.WebsiteTests/Tests/AuthenticationTests.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; -using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -17,7 +17,7 @@ public class AuthenticationTests : LighthouseWebTest [DatabaseFact] public async Task ShouldLoginWithPassword() { - await using Database database = new(); + await using DatabaseContext database = new(); Random random = new(); string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); @@ -39,7 +39,7 @@ public class AuthenticationTests : LighthouseWebTest [DatabaseFact] public async Task ShouldNotLoginWithNoPassword() { - await using Database database = new(); + await using DatabaseContext database = new(); Random random = new(); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("just like the hindenberg,")); @@ -58,7 +58,7 @@ public class AuthenticationTests : LighthouseWebTest [DatabaseFact] public async Task ShouldNotLoginWithWrongPassword() { - await using Database database = new(); + await using DatabaseContext database = new(); Random random = new(); 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]"; - await using Database database = new(); + await using DatabaseContext database = new(); Random random = new(); User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure")); diff --git a/ProjectLighthouse.Tests.WebsiteTests/Tests/RegisterTests.cs b/ProjectLighthouse.Tests.WebsiteTests/Tests/RegisterTests.cs index f0033a0a..037bceeb 100644 --- a/ProjectLighthouse.Tests.WebsiteTests/Tests/RegisterTests.cs +++ b/ProjectLighthouse.Tests.WebsiteTests/Tests/RegisterTests.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; -using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Tests; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -16,7 +16,7 @@ public class RegisterTests : LighthouseWebTest [DatabaseFact] public async Task ShouldRegister() { - await using Database database = new(); + await using DatabaseContext database = new(); string username = ("unitTestUser" + new Random().Next()).Substring(0, 16); string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); @@ -41,7 +41,7 @@ public class RegisterTests : LighthouseWebTest [DatabaseFact] public async Task ShouldNotRegisterWithMismatchingPasswords() { - await using Database database = new(); + await using DatabaseContext database = new(); string username = ("unitTestUser" + new Random().Next()).Substring(0, 16); string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); @@ -64,7 +64,7 @@ public class RegisterTests : LighthouseWebTest [DatabaseFact] public async Task ShouldNotRegisterWithTakenUsername() { - await using Database database = new(); + await using DatabaseContext database = new(); string username = ("unitTestUser" + new Random().Next())[..16]; string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); diff --git a/ProjectLighthouse.Tests/DatabaseFactAttribute.cs b/ProjectLighthouse.Tests/DatabaseFactAttribute.cs index 4bd92a87..8c54b1bb 100644 --- a/ProjectLighthouse.Tests/DatabaseFactAttribute.cs +++ b/ProjectLighthouse.Tests/DatabaseFactAttribute.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore; using Xunit; @@ -15,7 +16,7 @@ public sealed class DatabaseFactAttribute : FactAttribute else lock (migrateLock) { - using Database database = new(); + using DatabaseContext database = new(); database.Database.Migrate(); } } diff --git a/ProjectLighthouse.Tests/LighthouseServerTest.cs b/ProjectLighthouse.Tests/LighthouseServerTest.cs index 05e75e89..467d1158 100644 --- a/ProjectLighthouse.Tests/LighthouseServerTest.cs +++ b/ProjectLighthouse.Tests/LighthouseServerTest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Net.Http; using System.Threading.Tasks; using System.Xml.Serialization; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Tickets; @@ -34,7 +35,7 @@ public class LighthouseServerTest where TStartup : class if (createUser) { - await using Database database = new(); + await using DatabaseContext database = new(); if (await database.Users.FirstOrDefaultAsync(u => u.Username == $"{username}{number}") == null) { User user = await database.CreateUser($"{username}{number}", diff --git a/ProjectLighthouse/Administration/Maintenance/Commands/CreateAPIKeyCommand.cs b/ProjectLighthouse/Administration/Maintenance/Commands/CreateAPIKeyCommand.cs index f7e2a67a..353a74f5 100644 --- a/ProjectLighthouse/Administration/Maintenance/Commands/CreateAPIKeyCommand.cs +++ b/ProjectLighthouse/Administration/Maintenance/Commands/CreateAPIKeyCommand.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -24,7 +25,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands } key.Key = CryptoHelper.GenerateAuthToken(); key.Created = DateTime.Now; - Database database = new(); + DatabaseContext database = new(); await database.APIKeys.AddAsync(key); await database.SaveChangesAsync(); logger.LogSuccess($"The API key has been created (id: {key.Id}), however for security the token will only be shown once.", LogArea.Command); diff --git a/ProjectLighthouse/Administration/Maintenance/Commands/CreateUserCommand.cs b/ProjectLighthouse/Administration/Maintenance/Commands/CreateUserCommand.cs index d0018cb3..41d59a90 100644 --- a/ProjectLighthouse/Administration/Maintenance/Commands/CreateUserCommand.cs +++ b/ProjectLighthouse/Administration/Maintenance/Commands/CreateUserCommand.cs @@ -1,5 +1,6 @@ #nullable enable using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands; public class CreateUserCommand : ICommand { - private readonly Database _database = new(); + private readonly DatabaseContext _database = new(); public async Task Run(string[] args, Logger logger) { diff --git a/ProjectLighthouse/Administration/Maintenance/Commands/DeleteUserCommand.cs b/ProjectLighthouse/Administration/Maintenance/Commands/DeleteUserCommand.cs index 53768ec7..46b25ed7 100644 --- a/ProjectLighthouse/Administration/Maintenance/Commands/DeleteUserCommand.cs +++ b/ProjectLighthouse/Administration/Maintenance/Commands/DeleteUserCommand.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Logging; @@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands; public class DeleteUserCommand : ICommand { - private readonly Database database = new(); + private readonly DatabaseContext database = new(); public string Name() => "Delete User"; public string[] Aliases() => new[] diff --git a/ProjectLighthouse/Administration/Maintenance/Commands/RenameUserCommand.cs b/ProjectLighthouse/Administration/Maintenance/Commands/RenameUserCommand.cs index 5403cc17..3f717815 100644 --- a/ProjectLighthouse/Administration/Maintenance/Commands/RenameUserCommand.cs +++ b/ProjectLighthouse/Administration/Maintenance/Commands/RenameUserCommand.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Logging; @@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands; public class RenameUserCommand : ICommand { - private readonly Database database = new(); + private readonly DatabaseContext database = new(); public async Task Run(string[] args, Logger logger) { User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username == args[0]); diff --git a/ProjectLighthouse/Administration/Maintenance/Commands/ResetPasswordCommand.cs b/ProjectLighthouse/Administration/Maintenance/Commands/ResetPasswordCommand.cs index de3a2268..ce77d34d 100644 --- a/ProjectLighthouse/Administration/Maintenance/Commands/ResetPasswordCommand.cs +++ b/ProjectLighthouse/Administration/Maintenance/Commands/ResetPasswordCommand.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -12,7 +13,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands; public class ResetPasswordCommand : ICommand { - private readonly Database database = new(); + private readonly DatabaseContext database = new(); public string Name() => "Reset Password"; public string[] Aliases() => new[] diff --git a/ProjectLighthouse/Administration/Maintenance/Commands/WipeTokensForUserCommand.cs b/ProjectLighthouse/Administration/Maintenance/Commands/WipeTokensForUserCommand.cs index e19e723f..3084b475 100644 --- a/ProjectLighthouse/Administration/Maintenance/Commands/WipeTokensForUserCommand.cs +++ b/ProjectLighthouse/Administration/Maintenance/Commands/WipeTokensForUserCommand.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands; public class WipeTokensForUserCommand : ICommand { - private readonly Database database = new(); + private readonly DatabaseContext database = new(); public string Name() => "Wipe tokens for user"; public string[] Aliases() diff --git a/ProjectLighthouse/Administration/Maintenance/MaintenanceHelper.cs b/ProjectLighthouse/Administration/Maintenance/MaintenanceHelper.cs index 4efde5b1..e11e2f3d 100644 --- a/ProjectLighthouse/Administration/Maintenance/MaintenanceHelper.cs +++ b/ProjectLighthouse/Administration/Maintenance/MaintenanceHelper.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Linq; using System.Reflection; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Logging.Loggers; @@ -68,9 +69,9 @@ public static class MaintenanceHelper await job.Run(); } - public static async Task RunMigration(IMigrationTask migrationTask, Database? database = null) + public static async Task RunMigration(IMigrationTask migrationTask, DatabaseContext? database = null) { - database ??= new Database(); + database ??= new DatabaseContext(); // Migrations should never be run twice. Debug.Assert(!await database.CompletedMigrations.Has(m => m.MigrationName == migrationTask.GetType().Name)); diff --git a/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupBrokenPhotosMaintenanceJob.cs b/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupBrokenPhotosMaintenanceJob.cs index 6d060fdb..ca37856b 100644 --- a/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupBrokenPhotosMaintenanceJob.cs +++ b/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupBrokenPhotosMaintenanceJob.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -13,7 +14,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.MaintenanceJobs; public class CleanupBrokenPhotosMaintenanceJob : IMaintenanceJob { - private readonly Database database = new(); + private readonly DatabaseContext database = new(); public string Name() => "Cleanup Broken Photos"; public string Description() => "Deletes all photos that have missing assets or invalid photo subjects."; diff --git a/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupUnusedLocationsMaintenanceJob.cs b/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupUnusedLocationsMaintenanceJob.cs index b5a16c87..1488adcf 100644 --- a/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupUnusedLocationsMaintenanceJob.cs +++ b/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupUnusedLocationsMaintenanceJob.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Maintenance; using LBPUnion.ProjectLighthouse.Types.Misc; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.MaintenanceJobs; public class CleanupUnusedLocationsMaintenanceJob : IMaintenanceJob { - private readonly Database database = new(); + private readonly DatabaseContext database = new(); public string Name() => "Cleanup Unused Locations"; public string Description() => "Cleanup unused locations in the database."; diff --git a/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupUnusedPhotoSubjects.cs b/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupUnusedPhotoSubjects.cs index d75b7129..292dcd2e 100644 --- a/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupUnusedPhotoSubjects.cs +++ b/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/CleanupUnusedPhotoSubjects.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.MaintenanceJobs; public class CleanupUnusedPhotoSubjects : IMaintenanceJob { - private readonly Database database = new(); + private readonly DatabaseContext database = new(); public string Name() => "Cleanup Unused PhotoSubjects"; public string Description() => "Cleanup unused photo subjects in the database."; diff --git a/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/DeleteAllTokensMaintenanceJob.cs b/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/DeleteAllTokensMaintenanceJob.cs index 45f529c4..647f3f87 100644 --- a/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/DeleteAllTokensMaintenanceJob.cs +++ b/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/DeleteAllTokensMaintenanceJob.cs @@ -1,12 +1,13 @@ using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Maintenance; namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.MaintenanceJobs; public class DeleteAllTokensMaintenanceJob : IMaintenanceJob { - private readonly Database database = new(); + private readonly DatabaseContext database = new(); public string Name() => "Delete ALL Tokens"; public string Description() => "Deletes ALL game tokens and web tokens."; diff --git a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupBrokenVersusScoresMigration.cs b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupBrokenVersusScoresMigration.cs index 0bc4d066..a6963b69 100644 --- a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupBrokenVersusScoresMigration.cs +++ b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupBrokenVersusScoresMigration.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -8,7 +9,7 @@ public class FixBrokenVersusScores : IMigrationTask { public string Name() => "Cleanup versus scores"; - async Task IMigrationTask.Run(Database database) + async Task IMigrationTask.Run(DatabaseContext database) { foreach (Score score in database.Scores) { diff --git a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupDuplicateScoresMigration.cs b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupDuplicateScoresMigration.cs index 41208a58..8f63e9bd 100644 --- a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupDuplicateScoresMigration.cs +++ b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupDuplicateScoresMigration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Logging; @@ -12,7 +13,7 @@ public class CleanupDuplicateScoresMigration : IMigrationTask { public string Name() => "Cleanup duplicate scores"; - public async Task Run(Database database) + public async Task Run(DatabaseContext database) { List duplicateScoreIds = new(); // The original score should have the lowest score id diff --git a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupSlotVersionMismatchMigration.cs b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupSlotVersionMismatchMigration.cs index e6b15d38..eb7fd89a 100644 --- a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupSlotVersionMismatchMigration.cs +++ b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupSlotVersionMismatchMigration.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -11,7 +12,7 @@ public class CleanupSlotVersionMismatchMigration : IMigrationTask { public string Name() => "Cleanup slot versions"; - async Task IMigrationTask.Run(Database database) + async Task IMigrationTask.Run(DatabaseContext database) { foreach (Slot slot in database.Slots) { diff --git a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupXMLInjectionMigration.cs b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupXMLInjectionMigration.cs index 6e0a7193..e7fd205e 100644 --- a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupXMLInjectionMigration.cs +++ b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupXMLInjectionMigration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -10,7 +11,7 @@ public class CleanupXmlInjectionMigration : IMigrationTask public string Name() => "Cleanup XML injections"; // Weird, but required. Thanks, hejlsberg. - async Task IMigrationTask.Run(Database database) + async Task IMigrationTask.Run(DatabaseContext database) { List objsToBeSanitized = new(); diff --git a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/CleanupRoomsTask.cs b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/CleanupRoomsTask.cs index 601f64d3..1809d921 100644 --- a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/CleanupRoomsTask.cs +++ b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/CleanupRoomsTask.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -10,5 +11,5 @@ public class CleanupRoomsTask : IRepeatingTask public string Name => "Cleanup Rooms"; public TimeSpan RepeatInterval => TimeSpan.FromSeconds(10); public DateTime LastRan { get; set; } - public Task Run(Database database) => RoomHelper.CleanupRooms(); + public Task Run(DatabaseContext database) => RoomHelper.CleanupRooms(); } \ No newline at end of file diff --git a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/PerformCaseActionsTask.cs b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/PerformCaseActionsTask.cs index bda55263..26db6b8c 100644 --- a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/PerformCaseActionsTask.cs +++ b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/PerformCaseActionsTask.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; @@ -19,7 +20,7 @@ public class PerformCaseActionsTask : IRepeatingTask public string Name => "Perform actions on moderation cases"; public TimeSpan RepeatInterval => TimeSpan.FromSeconds(10); public DateTime LastRan { get; set; } - public async Task Run(Database database) + public async Task Run(DatabaseContext database) { foreach (ModerationCase @case in await database.Cases.Where(c => !c.Processed).ToListAsync()) { diff --git a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/RemoveExpiredTokensTask.cs b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/RemoveExpiredTokensTask.cs index 120c4dec..c8747b9d 100644 --- a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/RemoveExpiredTokensTask.cs +++ b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/RemoveExpiredTokensTask.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Maintenance; namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.RepeatingTasks; @@ -10,5 +11,5 @@ public class RemoveExpiredTokensTask : IRepeatingTask public TimeSpan RepeatInterval => TimeSpan.FromHours(1); public DateTime LastRan { get; set; } - public Task Run(Database database) => database.RemoveExpiredTokens(); + public Task Run(DatabaseContext database) => database.RemoveExpiredTokens(); } \ No newline at end of file diff --git a/ProjectLighthouse/Administration/RepeatingTaskHandler.cs b/ProjectLighthouse/Administration/RepeatingTaskHandler.cs index 832e896f..35ba1b36 100644 --- a/ProjectLighthouse/Administration/RepeatingTaskHandler.cs +++ b/ProjectLighthouse/Administration/RepeatingTaskHandler.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; using LBPUnion.ProjectLighthouse.Administration.Maintenance; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -30,7 +31,7 @@ public static class RepeatingTaskHandler Queue taskQueue = new(); foreach (IRepeatingTask task in MaintenanceHelper.RepeatingTasks) taskQueue.Enqueue(task); - Database database = new(); + DatabaseContext database = new(); while (true) { diff --git a/ProjectLighthouse/Configuration/ServerStatics.cs b/ProjectLighthouse/Configuration/ServerStatics.cs index e5c00848..fde1bdae 100644 --- a/ProjectLighthouse/Configuration/ServerStatics.cs +++ b/ProjectLighthouse/Configuration/ServerStatics.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Linq; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types.Logging; using LBPUnion.ProjectLighthouse.Types.Misc; @@ -15,7 +16,7 @@ public static class ServerStatics get { try { - using Database db = new(); + using DatabaseContext db = new(); return db.Database.CanConnect(); } catch(Exception e) diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs deleted file mode 100644 index 44752874..00000000 --- a/ProjectLighthouse/Database.cs +++ /dev/null @@ -1,619 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using LBPUnion.ProjectLighthouse.Configuration; -using LBPUnion.ProjectLighthouse.Extensions; -using LBPUnion.ProjectLighthouse.Helpers; -using LBPUnion.ProjectLighthouse.Tickets; -using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; -using LBPUnion.ProjectLighthouse.Types.Entities.Level; -using LBPUnion.ProjectLighthouse.Types.Entities.Maintenance; -using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; -using LBPUnion.ProjectLighthouse.Types.Entities.Profile; -using LBPUnion.ProjectLighthouse.Types.Entities.Token; -using LBPUnion.ProjectLighthouse.Types.Misc; -using Microsoft.AspNetCore.Http; -using Microsoft.EntityFrameworkCore; - -namespace LBPUnion.ProjectLighthouse; - -public class Database : DbContext -{ - #region Database entities - - #region Tokens - // ReSharper disable once InconsistentNaming - public DbSet APIKeys { get; set; } - public DbSet EmailSetTokens { get; set; } - public DbSet EmailVerificationTokens { get; set; } - public DbSet GameTokens { get; set; } - public DbSet PasswordResetTokens { get; set; } - public DbSet RegistrationTokens { get; set; } - public DbSet WebTokens { get; set; } - #endregion - - #region Users - public DbSet Comments { get; set; } - public DbSet LastContacts { get; set; } - public DbSet Locations { get; set; } - public DbSet Photos { get; set; } - public DbSet PhotoSubjects { get; set; } - public DbSet PlatformLinkAttempts { get; set; } - public DbSet Users { get; set; } - #endregion - - #region Levels - public DbSet CustomCategories { get; set; } - public DbSet Playlists { get; set; } - public DbSet Reviews { get; set; } - public DbSet Scores { get; set; } - public DbSet Slots { get; set; } - #endregion - - #region Interactions - public DbSet BlockedProfiles { get; set; } - public DbSet HeartedLevels { get; set; } - public DbSet HeartedPlaylists { get; set; } - public DbSet HeartedProfiles { get; set; } - public DbSet QueuedLevels { get; set; } - public DbSet RatedLevels { get; set; } - public DbSet RatedReviews { get; set; } - public DbSet Reactions { get; set; } - public DbSet VisitedLevels { get; set; } - #endregion - - #region Moderation - public DbSet Cases { get; set; } - public DbSet Reports { get; set; } - #endregion - - #region Misc - public DbSet CompletedMigrations { get; set; } - #endregion - - #endregion - - - protected override void OnConfiguring(DbContextOptionsBuilder options) - => options.UseMySql(ServerConfiguration.Instance.DbConnectionString, MySqlServerVersion.LatestSupportedServerVersion); - - #nullable enable - public async Task CreateUser(string username, string password, string? emailAddress = null) - { - if (!password.StartsWith('$')) throw new ArgumentException(nameof(password) + " is not a BCrypt hash"); - - // 16 is PSN max, 3 is PSN minimum - if (!ServerStatics.IsUnitTesting || !username.StartsWith("unitTestUser")) - { - if (username.Length > 16 || username.Length < 3) throw new ArgumentException(nameof(username) + " is either too long or too short"); - - Regex regex = new("^[a-zA-Z0-9_.-]*$"); - - if (!regex.IsMatch(username)) throw new ArgumentException(nameof(username) + " does not match the username regex"); - } - - User? user = await this.Users.Where(u => u.Username == username).FirstOrDefaultAsync(); - if (user != null) return user; - - Location l = new(); // store to get id after submitting - this.Locations.Add(l); // add to table - await this.SaveChangesAsync(); // saving to the database returns the id and sets it on this entity - - user = new User - { - Username = username, - Password = password, - LocationId = l.Id, - Biography = "", - EmailAddress = emailAddress, - }; - this.Users.Add(user); - - await this.SaveChangesAsync(); - - if (!ServerConfiguration.Instance.Mail.MailEnabled || emailAddress == null) return user; - - string body = "An account for Project Lighthouse has been registered with this email address.\n\n" + - $"You can login at {ServerConfiguration.Instance.ExternalUrl}."; - - SMTPHelper.SendEmail(emailAddress, "Project Lighthouse Account Created: " + username, body); - - return user; - } - - public async Task AuthenticateUser(User? user, NPTicket npTicket, string userLocation) - { - if (user == null) return null; - - GameToken gameToken = new() - { - UserToken = CryptoHelper.GenerateAuthToken(), - User = user, - UserId = user.UserId, - UserLocation = userLocation, - GameVersion = npTicket.GameVersion, - Platform = npTicket.Platform, - TicketHash = npTicket.TicketHash, - // we can get away with a low expiry here since LBP will just get a new token everytime it gets 403'd - ExpiresAt = DateTime.Now + TimeSpan.FromHours(1), - }; - - this.GameTokens.Add(gameToken); - await this.SaveChangesAsync(); - - return gameToken; - } - - #region Hearts & Queues - - public async Task RateComment(int userId, int commentId, int rating) - { - Comment? comment = await this.Comments.FirstOrDefaultAsync(c => commentId == c.CommentId); - - if (comment == null) return false; - if (comment.PosterUserId == userId) return false; - - if (await this.IsUserBlockedBy(userId, comment.PosterUserId)) return false; - - Reaction? reaction = await this.Reactions.FirstOrDefaultAsync(r => r.UserId == userId && r.TargetId == commentId); - if (reaction == null) - { - Reaction newReaction = new() - { - UserId = userId, - TargetId = commentId, - Rating = 0, - }; - this.Reactions.Add(newReaction); - await this.SaveChangesAsync(); - reaction = newReaction; - } - - rating = Math.Clamp(rating, -1, 1); - - int oldRating = reaction.Rating; - if (oldRating == rating) return true; - - reaction.Rating = rating; - // if rating changed then we count the number of reactions to ensure accuracy - List reactions = await this.Reactions.Where(c => c.TargetId == commentId).ToListAsync(); - int yay = 0; - int boo = 0; - foreach (Reaction r in reactions) - { - switch (r.Rating) - { - case -1: - boo++; - break; - case 1: - yay++; - break; - } - } - - comment.ThumbsDown = boo; - comment.ThumbsUp = yay; - await this.SaveChangesAsync(); - - return true; - } - - public async Task PostComment(int userId, int targetId, CommentType type, string message) - { - if (message.Length > 100) return false; - - if (type == CommentType.Profile) - { - int targetUserId = await this.Users.Where(u => u.UserId == targetId) - .Where(u => u.CommentsEnabled) - .Select(u => u.UserId) - .FirstOrDefaultAsync(); - if (targetUserId == 0) return false; - if (await this.IsUserBlockedBy(userId, targetUserId)) return false; - } - else - { - int creatorId = await this.Slots.Where(s => s.SlotId == targetId) - .Where(s => s.CommentsEnabled && !s.Hidden) - .Select(s => s.CreatorId) - .FirstOrDefaultAsync(); - if (creatorId == 0) return false; - - if (await this.IsUserBlockedBy(userId, creatorId)) return false; - } - - this.Comments.Add - ( - new Comment - { - PosterUserId = userId, - TargetId = targetId, - Type = type, - Message = message, - Timestamp = TimeHelper.TimestampMillis, - } - ); - await this.SaveChangesAsync(); - - return true; - } - - public async Task HeartUser(int userId, User heartedUser) - { - HeartedProfile? heartedProfile = await this.HeartedProfiles.FirstOrDefaultAsync(q => q.UserId == userId && q.HeartedUserId == heartedUser.UserId); - if (heartedProfile != null) return; - - this.HeartedProfiles.Add - ( - new HeartedProfile - { - HeartedUserId = heartedUser.UserId, - UserId = userId, - } - ); - - await this.SaveChangesAsync(); - } - - public async Task UnheartUser(int userId, User heartedUser) - { - HeartedProfile? heartedProfile = await this.HeartedProfiles.FirstOrDefaultAsync(q => q.UserId == userId && q.HeartedUserId == heartedUser.UserId); - if (heartedProfile != null) this.HeartedProfiles.Remove(heartedProfile); - - await this.SaveChangesAsync(); - } - - public async Task HeartPlaylist(int userId, Playlist heartedPlaylist) - { - HeartedPlaylist? heartedList = await this.HeartedPlaylists.FirstOrDefaultAsync(p => p.UserId == userId && p.PlaylistId == heartedPlaylist.PlaylistId); - if (heartedList != null) return; - - this.HeartedPlaylists.Add(new HeartedPlaylist() - { - PlaylistId = heartedPlaylist.PlaylistId, - UserId = userId, - }); - - await this.SaveChangesAsync(); - } - - public async Task UnheartPlaylist(int userId, Playlist heartedPlaylist) - { - HeartedPlaylist? heartedList = await this.HeartedPlaylists.FirstOrDefaultAsync(p => p.UserId == userId && p.PlaylistId == heartedPlaylist.PlaylistId); - if (heartedList != null) this.HeartedPlaylists.Remove(heartedList); - - await this.SaveChangesAsync(); - } - - public async Task HeartLevel(int userId, Slot heartedSlot) - { - HeartedLevel? heartedLevel = await this.HeartedLevels.FirstOrDefaultAsync(q => q.UserId == userId && q.SlotId == heartedSlot.SlotId); - if (heartedLevel != null) return; - - this.HeartedLevels.Add - ( - new HeartedLevel - { - SlotId = heartedSlot.SlotId, - UserId = userId, - } - ); - - await this.SaveChangesAsync(); - } - - public async Task UnheartLevel(int userId, Slot heartedSlot) - { - HeartedLevel? heartedLevel = await this.HeartedLevels.FirstOrDefaultAsync(q => q.UserId == userId && q.SlotId == heartedSlot.SlotId); - if (heartedLevel != null) this.HeartedLevels.Remove(heartedLevel); - - await this.SaveChangesAsync(); - } - - public async Task QueueLevel(int userId, Slot queuedSlot) - { - QueuedLevel? queuedLevel = await this.QueuedLevels.FirstOrDefaultAsync(q => q.UserId == userId && q.SlotId == queuedSlot.SlotId); - if (queuedLevel != null) return; - - this.QueuedLevels.Add - ( - new QueuedLevel - { - SlotId = queuedSlot.SlotId, - UserId = userId, - } - ); - - await this.SaveChangesAsync(); - } - - public async Task UnqueueLevel(int userId, Slot queuedSlot) - { - QueuedLevel? queuedLevel = await this.QueuedLevels.FirstOrDefaultAsync(q => q.UserId == userId && q.SlotId == queuedSlot.SlotId); - if (queuedLevel != null) this.QueuedLevels.Remove(queuedLevel); - - await this.SaveChangesAsync(); - } - - public async Task BlockUser(int userId, User blockedUser) - { - if (userId == blockedUser.UserId) return; - - User? user = await this.Users.FindAsync(userId); - - BlockedProfile blockedProfile = new() - { - User = user, - BlockedUser = blockedUser, - }; - - await this.BlockedProfiles.AddAsync(blockedProfile); - - await this.SaveChangesAsync(); - } - - public async Task UnblockUser(int userId, User blockedUser) - { - if (userId == blockedUser.UserId) return; - - this.BlockedProfiles.RemoveWhere(bp => bp.BlockedUserId == blockedUser.UserId && bp.UserId == userId); - - await this.SaveChangesAsync(); - } - - public async Task IsUserBlockedBy(int userId, int targetId) - { - if (targetId == userId) return false; - - return await this.BlockedProfiles.Has(bp => bp.BlockedUserId == userId && bp.UserId == targetId); - } - - #endregion - - #region User Helper Methods - - public async Task UserIdFromUsername(string? username) - { - if (username == null) return 0; - return await this.Users.Where(u => u.Username == username).Select(u => u.UserId).FirstOrDefaultAsync(); - } - - #endregion - - #region Game Token Shenanigans - - public async Task UsernameFromGameToken(GameToken? token) - { - if (token == null) return ""; - - return await this.Users.Where(u => u.UserId == token.UserId).Select(u => u.Username).FirstAsync(); - } - - public async Task UserFromGameToken(GameToken? token) - { - if (token == null) return null; - - return await this.Users.FirstOrDefaultAsync(u => u.UserId == token.UserId); - } - - private async Task UserFromMMAuth(string authToken) - { - GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == authToken); - - if (token == null) return null; - - if (DateTime.Now <= token.ExpiresAt) return await this.Users.FirstOrDefaultAsync(u => u.UserId == token.UserId); - - this.Remove(token); - await this.SaveChangesAsync(); - - return null; - } - - public async Task UserFromGameRequest(HttpRequest request) - { - if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth)) return null; - - return await this.UserFromMMAuth(mmAuth); - } - - public async Task GameTokenFromRequest(HttpRequest request) - { - if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth)) return null; - - GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); - - if (token == null) return null; - - if (DateTime.Now <= token.ExpiresAt) return token; - - this.Remove(token); - await this.SaveChangesAsync(); - - return null; - } - - public async Task<(User, GameToken)?> UserAndGameTokenFromRequest(HttpRequest request) - { - if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth)) return null; - - GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); - if (token == null) return null; - - if (DateTime.Now > token.ExpiresAt) - { - this.Remove(token); - await this.SaveChangesAsync(); - return null; - } - - User? user = await this.Users.FirstOrDefaultAsync(u => u.UserId == token.UserId); - if (user == null) return null; - - return (user, token); - } - - #endregion - - #region Web Token Shenanigans - - public async Task UsernameFromWebToken(WebToken? token) - { - if (token == null) return ""; - - return await this.Users.Where(u => u.UserId == token.UserId).Select(u => u.Username).FirstAsync(); - } - - private User? UserFromLighthouseToken(string lighthouseToken) - { - WebToken? token = this.WebTokens.FirstOrDefault(t => t.UserToken == lighthouseToken); - if (token == null) return null; - - if (DateTime.Now <= token.ExpiresAt) return this.Users.FirstOrDefault(u => u.UserId == token.UserId); - - this.Remove(token); - this.SaveChanges(); - - return null; - } - - public User? UserFromWebRequest(HttpRequest request) - { - if (!request.Cookies.TryGetValue("LighthouseToken", out string? lighthouseToken)) return null; - - return this.UserFromLighthouseToken(lighthouseToken); - } - - public WebToken? WebTokenFromRequest(HttpRequest request) - { - if (!request.Cookies.TryGetValue("LighthouseToken", out string? lighthouseToken)) return null; - - WebToken? token = this.WebTokens.FirstOrDefault(t => t.UserToken == lighthouseToken); - if (token == null) return null; - - if (DateTime.Now <= token.ExpiresAt) return token; - - this.Remove(token); - this.SaveChanges(); - - return null; - - } - - public async Task UserFromPasswordResetToken(string? resetToken) - { - if (string.IsNullOrWhiteSpace(resetToken)) return null; - - PasswordResetToken? token = await this.PasswordResetTokens.FirstOrDefaultAsync(token => token.ResetToken == resetToken); - if (token == null) return null; - - if (token.Created >= DateTime.Now.AddHours(-1)) - return await this.Users.FirstOrDefaultAsync(user => user.UserId == token.UserId); - - this.PasswordResetTokens.Remove(token); - await this.SaveChangesAsync(); - - return null; - } - - public bool IsRegistrationTokenValid(string? tokenString) - { - if (string.IsNullOrWhiteSpace(tokenString)) return false; - - RegistrationToken? token = this.RegistrationTokens.FirstOrDefault(t => t.Token == tokenString); - if (token == null) return false; - - if (token.Created >= DateTime.Now.AddDays(-7)) return true; - - this.RegistrationTokens.Remove(token); - this.SaveChanges(); - - return false; - - } - - public async Task RemoveExpiredTokens() - { - foreach (GameToken token in await this.GameTokens.Where(t => DateTime.Now > t.ExpiresAt).ToListAsync()) - { - User? user = await this.Users.FirstOrDefaultAsync(u => u.UserId == token.UserId); - if (user != null) user.LastLogout = TimeHelper.TimestampMillis; - this.GameTokens.Remove(token); - } - this.WebTokens.RemoveWhere(t => DateTime.Now > t.ExpiresAt); - this.EmailVerificationTokens.RemoveWhere(t => DateTime.Now > t.ExpiresAt); - this.EmailSetTokens.RemoveWhere(t => DateTime.Now > t.ExpiresAt); - - await this.SaveChangesAsync(); - } - - public async Task RemoveRegistrationToken(string? tokenString) - { - if (string.IsNullOrWhiteSpace(tokenString)) return; - - RegistrationToken? token = await this.RegistrationTokens.FirstOrDefaultAsync(t => t.Token == tokenString); - if (token == null) return; - - this.RegistrationTokens.Remove(token); - - await this.SaveChangesAsync(); - } - - #endregion - - public async Task PhotoFromSubject(PhotoSubject subject) - => await this.Photos.FirstOrDefaultAsync(p => p.PhotoSubjectIds.Contains(subject.PhotoSubjectId.ToString())); - public async Task RemoveUser(User? user) - { - if (user == null) return; - if (user.Username.Length == 0) return; // don't delete the placeholder user - - if (user.Location != null) this.Locations.Remove(user.Location); - - LastContact? lastContact = await this.LastContacts.FirstOrDefaultAsync(l => l.UserId == user.UserId); - if (lastContact != null) this.LastContacts.Remove(lastContact); - - foreach (ModerationCase modCase in await this.Cases - .Where(c => c.CreatorId == user.UserId || c.DismisserId == user.UserId) - .ToListAsync()) - { - if(modCase.DismisserId == user.UserId) - modCase.DismisserId = null; - if(modCase.CreatorId == user.UserId) - modCase.CreatorId = await SlotHelper.GetPlaceholderUserId(this); - } - - foreach (Slot slot in this.Slots.Where(s => s.CreatorId == user.UserId)) await this.RemoveSlot(slot, false); - - this.HeartedProfiles.RemoveRange(this.HeartedProfiles.Where(h => h.UserId == user.UserId)); - this.PhotoSubjects.RemoveRange(this.PhotoSubjects.Where(s => s.UserId == user.UserId)); - this.HeartedLevels.RemoveRange(this.HeartedLevels.Where(h => h.UserId == user.UserId)); - this.VisitedLevels.RemoveRange(this.VisitedLevels.Where(v => v.UserId == user.UserId)); - this.RatedReviews.RemoveRange(this.RatedReviews.Where(r => r.UserId == user.UserId)); - this.QueuedLevels.RemoveRange(this.QueuedLevels.Where(q => q.UserId == user.UserId)); - this.RatedLevels.RemoveRange(this.RatedLevels.Where(r => r.UserId == user.UserId)); - this.GameTokens.RemoveRange(this.GameTokens.Where(t => t.UserId == user.UserId)); - this.WebTokens.RemoveRange(this.WebTokens.Where(t => t.UserId == user.UserId)); - this.Reactions.RemoveRange(this.Reactions.Where(p => p.UserId == user.UserId)); - this.Comments.RemoveRange(this.Comments.Where(c => c.PosterUserId == user.UserId)); - this.Reviews.RemoveRange(this.Reviews.Where(r => r.ReviewerId == user.UserId)); - this.Photos.RemoveRange(this.Photos.Where(p => p.CreatorId == user.UserId)); - - this.Users.Remove(user); - - await this.SaveChangesAsync(); - } - - public async Task RemoveSlot(Slot slot, bool saveChanges = true) - { - if (slot.Location != null) this.Locations.Remove(slot.Location); - - this.Slots.Remove(slot); - - if (saveChanges) await this.SaveChangesAsync(); - } - #nullable disable -} diff --git a/ProjectLighthouse/Database/DatabaseComments.cs b/ProjectLighthouse/Database/DatabaseComments.cs new file mode 100644 index 00000000..fff673bb --- /dev/null +++ b/ProjectLighthouse/Database/DatabaseComments.cs @@ -0,0 +1,107 @@ +#nullable enable +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; +using LBPUnion.ProjectLighthouse.Types.Entities.Profile; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Database; + +public partial class DatabaseContext +{ + public async Task RateComment(int userId, int commentId, int rating) + { + Comment? comment = await this.Comments.FirstOrDefaultAsync(c => commentId == c.CommentId); + + if (comment == null) return false; + if (comment.PosterUserId == userId) return false; + + if (await this.IsUserBlockedBy(userId, comment.PosterUserId)) return false; + + Reaction? reaction = await this.Reactions.FirstOrDefaultAsync(r => r.UserId == userId && r.TargetId == commentId); + if (reaction == null) + { + Reaction newReaction = new() + { + UserId = userId, + TargetId = commentId, + Rating = 0, + }; + this.Reactions.Add(newReaction); + await this.SaveChangesAsync(); + reaction = newReaction; + } + + rating = Math.Clamp(rating, -1, 1); + + int oldRating = reaction.Rating; + if (oldRating == rating) return true; + + reaction.Rating = rating; + // if rating changed then we count the number of reactions to ensure accuracy + List reactions = await this.Reactions.Where(c => c.TargetId == commentId).ToListAsync(); + int yay = 0; + int boo = 0; + foreach (Reaction r in reactions) + { + switch (r.Rating) + { + case -1: + boo++; + break; + case 1: + yay++; + break; + } + } + + comment.ThumbsDown = boo; + comment.ThumbsUp = yay; + await this.SaveChangesAsync(); + + return true; + } + + public async Task PostComment(int userId, int targetId, CommentType type, string message) + { + if (message.Length > 100) return false; + + if (type == CommentType.Profile) + { + int targetUserId = await this.Users.Where(u => u.UserId == targetId) + .Where(u => u.CommentsEnabled) + .Select(u => u.UserId) + .FirstOrDefaultAsync(); + if (targetUserId == 0) return false; + if (await this.IsUserBlockedBy(userId, targetUserId)) return false; + } + else + { + int creatorId = await this.Slots.Where(s => s.SlotId == targetId) + .Where(s => s.CommentsEnabled && !s.Hidden) + .Select(s => s.CreatorId) + .FirstOrDefaultAsync(); + if (creatorId == 0) return false; + + if (await this.IsUserBlockedBy(userId, creatorId)) return false; + } + + this.Comments.Add + ( + new Comment + { + PosterUserId = userId, + TargetId = targetId, + Type = type, + Message = message, + Timestamp = TimeHelper.TimestampMillis, + } + ); + await this.SaveChangesAsync(); + + return true; + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Database/DatabaseContext.cs b/ProjectLighthouse/Database/DatabaseContext.cs new file mode 100644 index 00000000..d8c3bf97 --- /dev/null +++ b/ProjectLighthouse/Database/DatabaseContext.cs @@ -0,0 +1,71 @@ +using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; +using LBPUnion.ProjectLighthouse.Types.Entities.Level; +using LBPUnion.ProjectLighthouse.Types.Entities.Maintenance; +using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; +using LBPUnion.ProjectLighthouse.Types.Entities.Profile; +using LBPUnion.ProjectLighthouse.Types.Entities.Token; +using LBPUnion.ProjectLighthouse.Types.Misc; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Database; + +public partial class DatabaseContext : DbContext +{ + #region Database entities + + #region Tokens + // ReSharper disable once InconsistentNaming + public DbSet APIKeys { get; set; } + public DbSet EmailSetTokens { get; set; } + public DbSet EmailVerificationTokens { get; set; } + public DbSet GameTokens { get; set; } + public DbSet PasswordResetTokens { get; set; } + public DbSet RegistrationTokens { get; set; } + public DbSet WebTokens { get; set; } + #endregion + + #region Users + public DbSet Comments { get; set; } + public DbSet LastContacts { get; set; } + public DbSet Locations { get; set; } + public DbSet Photos { get; set; } + public DbSet PhotoSubjects { get; set; } + public DbSet PlatformLinkAttempts { get; set; } + public DbSet Users { get; set; } + #endregion + + #region Levels + public DbSet CustomCategories { get; set; } + public DbSet Playlists { get; set; } + public DbSet Reviews { get; set; } + public DbSet Scores { get; set; } + public DbSet Slots { get; set; } + #endregion + + #region Interactions + public DbSet BlockedProfiles { get; set; } + public DbSet HeartedLevels { get; set; } + public DbSet HeartedPlaylists { get; set; } + public DbSet HeartedProfiles { get; set; } + public DbSet QueuedLevels { get; set; } + public DbSet RatedLevels { get; set; } + public DbSet RatedReviews { get; set; } + public DbSet Reactions { get; set; } + public DbSet VisitedLevels { get; set; } + #endregion + + #region Moderation + public DbSet Cases { get; set; } + public DbSet Reports { get; set; } + #endregion + + #region Misc + public DbSet CompletedMigrations { get; set; } + #endregion + + #endregion + + protected override void OnConfiguring(DbContextOptionsBuilder options) + => options.UseMySql(ServerConfiguration.Instance.DbConnectionString, MySqlServerVersion.LatestSupportedServerVersion); +} diff --git a/ProjectLighthouse/Database/DatabaseGameTokens.cs b/ProjectLighthouse/Database/DatabaseGameTokens.cs new file mode 100644 index 00000000..46c44bb9 --- /dev/null +++ b/ProjectLighthouse/Database/DatabaseGameTokens.cs @@ -0,0 +1,66 @@ +#nullable enable +using System; +using System.Linq; +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Types.Entities.Profile; +using LBPUnion.ProjectLighthouse.Types.Entities.Token; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Database; + +public partial class DatabaseContext +{ + + public async Task UsernameFromGameToken(GameToken? token) + { + if (token == null) return ""; + + return await this.Users.Where(u => u.UserId == token.UserId).Select(u => u.Username).FirstAsync(); + } + + public async Task UserFromGameToken(GameToken? token) + { + if (token == null) return null; + + return await this.Users.FirstOrDefaultAsync(u => u.UserId == token.UserId); + } + + private async Task UserFromMMAuth(string authToken) + { + GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == authToken); + + if (token == null) return null; + + if (DateTime.Now <= token.ExpiresAt) return await this.Users.FirstOrDefaultAsync(u => u.UserId == token.UserId); + + this.Remove(token); + await this.SaveChangesAsync(); + + return null; + } + + public async Task UserFromGameRequest(HttpRequest request) + { + if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth)) return null; + + return await this.UserFromMMAuth(mmAuth); + } + + public async Task GameTokenFromRequest(HttpRequest request) + { + if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth)) return null; + + GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); + + if (token == null) return null; + + if (DateTime.Now <= token.ExpiresAt) return token; + + this.Remove(token); + await this.SaveChangesAsync(); + + return null; + } + +} \ No newline at end of file diff --git a/ProjectLighthouse/Database/DatabaseSlotUtils.cs b/ProjectLighthouse/Database/DatabaseSlotUtils.cs new file mode 100644 index 00000000..0e151908 --- /dev/null +++ b/ProjectLighthouse/Database/DatabaseSlotUtils.cs @@ -0,0 +1,92 @@ +#nullable enable +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; +using LBPUnion.ProjectLighthouse.Types.Entities.Level; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Database; + +public partial class DatabaseContext +{ + public async Task RemoveSlot(Slot slot, bool saveChanges = true) + { + if (slot.Location != null) this.Locations.Remove(slot.Location); + + this.Slots.Remove(slot); + + if (saveChanges) await this.SaveChangesAsync(); + } + + public async Task HeartPlaylist(int userId, Playlist heartedPlaylist) + { + HeartedPlaylist? heartedList = await this.HeartedPlaylists.FirstOrDefaultAsync(p => p.UserId == userId && p.PlaylistId == heartedPlaylist.PlaylistId); + if (heartedList != null) return; + + this.HeartedPlaylists.Add(new HeartedPlaylist() + { + PlaylistId = heartedPlaylist.PlaylistId, + UserId = userId, + }); + + await this.SaveChangesAsync(); + } + + public async Task UnheartPlaylist(int userId, Playlist heartedPlaylist) + { + HeartedPlaylist? heartedList = await this.HeartedPlaylists.FirstOrDefaultAsync(p => p.UserId == userId && p.PlaylistId == heartedPlaylist.PlaylistId); + if (heartedList != null) this.HeartedPlaylists.Remove(heartedList); + + await this.SaveChangesAsync(); + } + + public async Task HeartLevel(int userId, Slot heartedSlot) + { + HeartedLevel? heartedLevel = await this.HeartedLevels.FirstOrDefaultAsync(q => q.UserId == userId && q.SlotId == heartedSlot.SlotId); + if (heartedLevel != null) return; + + this.HeartedLevels.Add + ( + new HeartedLevel + { + SlotId = heartedSlot.SlotId, + UserId = userId, + } + ); + + await this.SaveChangesAsync(); + } + + public async Task UnheartLevel(int userId, Slot heartedSlot) + { + HeartedLevel? heartedLevel = await this.HeartedLevels.FirstOrDefaultAsync(q => q.UserId == userId && q.SlotId == heartedSlot.SlotId); + if (heartedLevel != null) this.HeartedLevels.Remove(heartedLevel); + + await this.SaveChangesAsync(); + } + + public async Task QueueLevel(int userId, Slot queuedSlot) + { + QueuedLevel? queuedLevel = await this.QueuedLevels.FirstOrDefaultAsync(q => q.UserId == userId && q.SlotId == queuedSlot.SlotId); + if (queuedLevel != null) return; + + this.QueuedLevels.Add + ( + new QueuedLevel + { + SlotId = queuedSlot.SlotId, + UserId = userId, + } + ); + + await this.SaveChangesAsync(); + } + + public async Task UnqueueLevel(int userId, Slot queuedSlot) + { + QueuedLevel? queuedLevel = await this.QueuedLevels.FirstOrDefaultAsync(q => q.UserId == userId && q.SlotId == queuedSlot.SlotId); + if (queuedLevel != null) this.QueuedLevels.Remove(queuedLevel); + + await this.SaveChangesAsync(); + } + +} \ No newline at end of file diff --git a/ProjectLighthouse/Database/DatabaseUserUtils.cs b/ProjectLighthouse/Database/DatabaseUserUtils.cs new file mode 100644 index 00000000..f9478a6d --- /dev/null +++ b/ProjectLighthouse/Database/DatabaseUserUtils.cs @@ -0,0 +1,193 @@ +using System; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Extensions; +using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Tickets; +using LBPUnion.ProjectLighthouse.Types.Entities.Interaction; +using LBPUnion.ProjectLighthouse.Types.Entities.Level; +using LBPUnion.ProjectLighthouse.Types.Entities.Moderation; +using LBPUnion.ProjectLighthouse.Types.Entities.Profile; +using LBPUnion.ProjectLighthouse.Types.Entities.Token; +using LBPUnion.ProjectLighthouse.Types.Misc; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Database; + +public partial class DatabaseContext +{ + [GeneratedRegex("^[a-zA-Z0-9_.-]{3,16}$")] + private static partial Regex UsernameRegex(); + + #nullable enable + public async Task CreateUser(string username, string password, string? emailAddress = null) + { + if (!password.StartsWith('$')) throw new ArgumentException(nameof(password) + " is not a BCrypt hash"); + + // 16 is PSN max, 3 is PSN minimum + if (!ServerStatics.IsUnitTesting || !username.StartsWith("unitTestUser")) + { + if (username.Length is > 16 or < 3) throw new ArgumentException(nameof(username) + " is either too long or too short"); + + Regex regex = UsernameRegex(); + + if (!regex.IsMatch(username)) throw new ArgumentException(nameof(username) + " does not match the username regex"); + } + + User? user = await this.Users.Where(u => u.Username == username).FirstOrDefaultAsync(); + if (user != null) return user; + + Location l = new(); // store to get id after submitting + this.Locations.Add(l); // add to table + await this.SaveChangesAsync(); // saving to the database returns the id and sets it on this entity + + user = new User + { + Username = username, + Password = password, + LocationId = l.Id, + Biography = "", + EmailAddress = emailAddress, + }; + this.Users.Add(user); + + await this.SaveChangesAsync(); + + if (!ServerConfiguration.Instance.Mail.MailEnabled || emailAddress == null) return user; + + string body = "An account for Project Lighthouse has been registered with this email address.\n\n" + + $"You can login at {ServerConfiguration.Instance.ExternalUrl}."; + + SMTPHelper.SendEmail(emailAddress, "Project Lighthouse Account Created: " + username, body); + + return user; + } + + public async Task UserIdFromUsername(string? username) + { + if (username == null) return 0; + return await this.Users.Where(u => u.Username == username).Select(u => u.UserId).FirstOrDefaultAsync(); + } + + public async Task AuthenticateUser(User? user, NPTicket npTicket, string userLocation) + { + if (user == null) return null; + + GameToken gameToken = new() + { + UserToken = CryptoHelper.GenerateAuthToken(), + User = user, + UserId = user.UserId, + UserLocation = userLocation, + GameVersion = npTicket.GameVersion, + Platform = npTicket.Platform, + TicketHash = npTicket.TicketHash, + // we can get away with a low expiry here since LBP will just get a new token everytime it gets 403'd + ExpiresAt = DateTime.Now + TimeSpan.FromHours(1), + }; + + this.GameTokens.Add(gameToken); + await this.SaveChangesAsync(); + + return gameToken; + } + + public async Task RemoveUser(User? user) + { + if (user == null) return; + if (user.Username.Length == 0) return; // don't delete the placeholder user + + if (user.Location != null) this.Locations.Remove(user.Location); + + LastContact? lastContact = await this.LastContacts.FirstOrDefaultAsync(l => l.UserId == user.UserId); + if (lastContact != null) this.LastContacts.Remove(lastContact); + + foreach (ModerationCase modCase in await this.Cases + .Where(c => c.CreatorId == user.UserId || c.DismisserId == user.UserId) + .ToListAsync()) + { + if(modCase.DismisserId == user.UserId) + modCase.DismisserId = null; + if(modCase.CreatorId == user.UserId) + modCase.CreatorId = await SlotHelper.GetPlaceholderUserId(this); + } + + foreach (Slot slot in this.Slots.Where(s => s.CreatorId == user.UserId)) await this.RemoveSlot(slot, false); + + this.HeartedProfiles.RemoveRange(this.HeartedProfiles.Where(h => h.UserId == user.UserId)); + this.PhotoSubjects.RemoveRange(this.PhotoSubjects.Where(s => s.UserId == user.UserId)); + this.HeartedLevels.RemoveRange(this.HeartedLevels.Where(h => h.UserId == user.UserId)); + this.VisitedLevels.RemoveRange(this.VisitedLevels.Where(v => v.UserId == user.UserId)); + this.RatedReviews.RemoveRange(this.RatedReviews.Where(r => r.UserId == user.UserId)); + this.QueuedLevels.RemoveRange(this.QueuedLevels.Where(q => q.UserId == user.UserId)); + this.RatedLevels.RemoveRange(this.RatedLevels.Where(r => r.UserId == user.UserId)); + this.GameTokens.RemoveRange(this.GameTokens.Where(t => t.UserId == user.UserId)); + this.WebTokens.RemoveRange(this.WebTokens.Where(t => t.UserId == user.UserId)); + this.Reactions.RemoveRange(this.Reactions.Where(p => p.UserId == user.UserId)); + this.Comments.RemoveRange(this.Comments.Where(c => c.PosterUserId == user.UserId)); + this.Reviews.RemoveRange(this.Reviews.Where(r => r.ReviewerId == user.UserId)); + this.Photos.RemoveRange(this.Photos.Where(p => p.CreatorId == user.UserId)); + + this.Users.Remove(user); + + await this.SaveChangesAsync(); + } + + public async Task HeartUser(int userId, User heartedUser) + { + HeartedProfile? heartedProfile = await this.HeartedProfiles.FirstOrDefaultAsync(q => q.UserId == userId && q.HeartedUserId == heartedUser.UserId); + if (heartedProfile != null) return; + + this.HeartedProfiles.Add(new HeartedProfile + { + HeartedUserId = heartedUser.UserId, + UserId = userId, + }); + + await this.SaveChangesAsync(); + } + + public async Task UnheartUser(int userId, User heartedUser) + { + HeartedProfile? heartedProfile = await this.HeartedProfiles.FirstOrDefaultAsync(q => q.UserId == userId && q.HeartedUserId == heartedUser.UserId); + if (heartedProfile != null) this.HeartedProfiles.Remove(heartedProfile); + + await this.SaveChangesAsync(); + } + + public async Task BlockUser(int userId, User blockedUser) + { + if (userId == blockedUser.UserId) return; + + User? user = await this.Users.FindAsync(userId); + + BlockedProfile blockedProfile = new() + { + User = user, + BlockedUser = blockedUser, + }; + + await this.BlockedProfiles.AddAsync(blockedProfile); + + await this.SaveChangesAsync(); + } + + public async Task UnblockUser(int userId, User blockedUser) + { + if (userId == blockedUser.UserId) return; + + this.BlockedProfiles.RemoveWhere(bp => bp.BlockedUserId == blockedUser.UserId && bp.UserId == userId); + + await this.SaveChangesAsync(); + } + + public async Task IsUserBlockedBy(int userId, int targetId) + { + if (targetId == userId) return false; + + return await this.BlockedProfiles.Has(bp => bp.BlockedUserId == userId && bp.UserId == targetId); + } + +} \ No newline at end of file diff --git a/ProjectLighthouse/Database/DatabaseWebTokens.cs b/ProjectLighthouse/Database/DatabaseWebTokens.cs new file mode 100644 index 00000000..016f3a80 --- /dev/null +++ b/ProjectLighthouse/Database/DatabaseWebTokens.cs @@ -0,0 +1,119 @@ +#nullable enable +using System; +using System.Linq; +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Extensions; +using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Types.Entities.Profile; +using LBPUnion.ProjectLighthouse.Types.Entities.Token; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Database; + +public partial class DatabaseContext +{ + public async Task UsernameFromWebToken(WebToken? token) + { + if (token == null) return ""; + + return await this.Users.Where(u => u.UserId == token.UserId).Select(u => u.Username).FirstAsync(); + } + + private User? UserFromLighthouseToken(string lighthouseToken) + { + WebToken? token = this.WebTokens.FirstOrDefault(t => t.UserToken == lighthouseToken); + if (token == null) return null; + + if (DateTime.Now <= token.ExpiresAt) return this.Users.FirstOrDefault(u => u.UserId == token.UserId); + + this.Remove(token); + this.SaveChanges(); + + return null; + } + + public User? UserFromWebRequest(HttpRequest request) + { + if (!request.Cookies.TryGetValue("LighthouseToken", out string? lighthouseToken)) return null; + + return this.UserFromLighthouseToken(lighthouseToken); + } + + public WebToken? WebTokenFromRequest(HttpRequest request) + { + if (!request.Cookies.TryGetValue("LighthouseToken", out string? lighthouseToken)) return null; + + WebToken? token = this.WebTokens.FirstOrDefault(t => t.UserToken == lighthouseToken); + if (token == null) return null; + + if (DateTime.Now <= token.ExpiresAt) return token; + + this.Remove(token); + this.SaveChanges(); + + return null; + + } + + public async Task UserFromPasswordResetToken(string? resetToken) + { + if (string.IsNullOrWhiteSpace(resetToken)) return null; + + PasswordResetToken? token = + await this.PasswordResetTokens.FirstOrDefaultAsync(token => token.ResetToken == resetToken); + if (token == null) return null; + + if (token.Created >= DateTime.Now.AddHours(-1)) + return await this.Users.FirstOrDefaultAsync(user => user.UserId == token.UserId); + + this.PasswordResetTokens.Remove(token); + await this.SaveChangesAsync(); + + return null; + } + + public bool IsRegistrationTokenValid(string? tokenString) + { + if (string.IsNullOrWhiteSpace(tokenString)) return false; + + RegistrationToken? token = this.RegistrationTokens.FirstOrDefault(t => t.Token == tokenString); + if (token == null) return false; + + if (token.Created >= DateTime.Now.AddDays(-7)) return true; + + this.RegistrationTokens.Remove(token); + this.SaveChanges(); + + return false; + + } + + public async Task RemoveExpiredTokens() + { + foreach (GameToken token in await this.GameTokens.Where(t => DateTime.Now > t.ExpiresAt).ToListAsync()) + { + User? user = await this.Users.FirstOrDefaultAsync(u => u.UserId == token.UserId); + if (user != null) user.LastLogout = TimeHelper.TimestampMillis; + this.GameTokens.Remove(token); + } + + this.WebTokens.RemoveWhere(t => DateTime.Now > t.ExpiresAt); + this.EmailVerificationTokens.RemoveWhere(t => DateTime.Now > t.ExpiresAt); + this.EmailSetTokens.RemoveWhere(t => DateTime.Now > t.ExpiresAt); + + await this.SaveChangesAsync(); + } + + public async Task RemoveRegistrationToken(string? tokenString) + { + if (string.IsNullOrWhiteSpace(tokenString)) return; + + RegistrationToken? token = await this.RegistrationTokens.FirstOrDefaultAsync(t => t.Token == tokenString); + if (token == null) return; + + this.RegistrationTokens.Remove(token); + + await this.SaveChangesAsync(); + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Extensions/RoomExtensions.cs b/ProjectLighthouse/Extensions/RoomExtensions.cs index d53cf738..3551d313 100644 --- a/ProjectLighthouse/Extensions/RoomExtensions.cs +++ b/ProjectLighthouse/Extensions/RoomExtensions.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms; @@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Extensions; public static class RoomExtensions { - public static List GetPlayers(this Room room, Database database) + public static List GetPlayers(this Room room, DatabaseContext database) { List players = new(); foreach (int playerId in room.PlayerIds) diff --git a/ProjectLighthouse/Helpers/EmailHelper.cs b/ProjectLighthouse/Helpers/EmailHelper.cs index 9754414c..f9325cc1 100644 --- a/ProjectLighthouse/Helpers/EmailHelper.cs +++ b/ProjectLighthouse/Helpers/EmailHelper.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Token; @@ -17,7 +18,7 @@ public partial class SMTPHelper // (User id, timestamp of last request + 30 seconds) private static readonly ConcurrentDictionary recentlySentEmail = new(); - public static async Task SendVerificationEmail(Database database, User user) + public static async Task SendVerificationEmail(DatabaseContext database, User user) { // Remove expired entries for (int i = recentlySentEmail.Count - 1; i >= 0; i--) diff --git a/ProjectLighthouse/Helpers/LastContactHelper.cs b/ProjectLighthouse/Helpers/LastContactHelper.cs index 4d20bf19..d53d2284 100644 --- a/ProjectLighthouse/Helpers/LastContactHelper.cs +++ b/ProjectLighthouse/Helpers/LastContactHelper.cs @@ -1,6 +1,7 @@ #nullable enable using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Users; using Microsoft.EntityFrameworkCore; @@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers; public static class LastContactHelper { - public static async Task SetLastContact(Database database, User user, GameVersion gameVersion, Platform platform) + public static async Task SetLastContact(DatabaseContext database, User user, GameVersion gameVersion, Platform platform) { LastContact? lastContact = await database.LastContacts.Where(l => l.UserId == user.UserId).FirstOrDefaultAsync(); diff --git a/ProjectLighthouse/Helpers/ResourceHelper.cs b/ProjectLighthouse/Helpers/ResourceHelper.cs index ebfd55e3..fc9a1ee1 100644 --- a/ProjectLighthouse/Helpers/ResourceHelper.cs +++ b/ProjectLighthouse/Helpers/ResourceHelper.cs @@ -7,7 +7,7 @@ public static class ResourceHelper { public static string ReadManifestFile(string fileName) { - using Stream stream = typeof(Database).Assembly.GetManifestResourceStream($"{typeof(Database).Namespace}.{fileName}"); + using Stream stream = typeof(StartupTasks).Assembly.GetManifestResourceStream($"{typeof(StartupTasks).Namespace}.{fileName}"); using StreamReader reader = new(stream ?? throw new Exception("The assembly or manifest resource is null.")); return reader.ReadToEnd().Trim(); diff --git a/ProjectLighthouse/Helpers/RoomHelper.cs b/ProjectLighthouse/Helpers/RoomHelper.cs index 9ae5a7cd..6c00e0bf 100644 --- a/ProjectLighthouse/Helpers/RoomHelper.cs +++ b/ProjectLighthouse/Helpers/RoomHelper.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.StorableLists; @@ -84,7 +85,7 @@ public class RoomHelper response.Players = new List(); response.Locations = new List(); - foreach (User player in room.GetPlayers(new Database())) + foreach (User player in room.GetPlayers(new DatabaseContext())) { response.Players.Add ( @@ -186,7 +187,7 @@ public class RoomHelper } [SuppressMessage("ReSharper", "InvertIf")] - public static Task CleanupRooms(int? hostId = null, Room? newRoom = null, Database? database = null) + public static Task CleanupRooms(int? hostId = null, Room? newRoom = null, DatabaseContext? database = null) { #if DEBUG Stopwatch stopwatch = new(); @@ -205,7 +206,7 @@ public class RoomHelper // Remove offline players from rooms foreach (Room room in rooms) { - List players = room.GetPlayers(database ?? new Database()); + List players = room.GetPlayers(database ?? new DatabaseContext()); List playersToRemove = players.Where(player => player.Status.StatusType == StatusType.Offline).Select(player => player.UserId).ToList(); foreach (int player in playersToRemove) room.PlayerIds.Remove(player); diff --git a/ProjectLighthouse/Helpers/SlotHelper.cs b/ProjectLighthouse/Helpers/SlotHelper.cs index b07c46e3..28e80b4f 100644 --- a/ProjectLighthouse/Helpers/SlotHelper.cs +++ b/ProjectLighthouse/Helpers/SlotHelper.cs @@ -3,6 +3,7 @@ using System; using System.Linq; using System.Threading; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Levels; @@ -43,7 +44,7 @@ public static class SlotHelper private static readonly SemaphoreSlim semaphore = new(1, 1); - private static async Task GetPlaceholderLocationId(Database database) + private static async Task GetPlaceholderLocationId(DatabaseContext database) { Location? devLocation = await database.Locations.FirstOrDefaultAsync(l => l.Id == 1); @@ -65,7 +66,7 @@ public static class SlotHelper } } - public static async Task GetPlaceholderUserId(Database database) + public static async Task GetPlaceholderUserId(DatabaseContext database) { int devCreatorId = await database.Users.Where(u => u.Username.Length == 0) .Select(u => u.UserId) @@ -93,7 +94,7 @@ public static class SlotHelper } } - public static async Task GetPlaceholderSlotId(Database database, int guid, SlotType slotType) + public static async Task GetPlaceholderSlotId(DatabaseContext database, int guid, SlotType slotType) { int slotId = await database.Slots.Where(s => s.Type == slotType && s.InternalSlotId == guid).Select(s => s.SlotId).FirstOrDefaultAsync(); if (slotId != 0) return slotId; diff --git a/ProjectLighthouse/Helpers/StatisticsHelper.cs b/ProjectLighthouse/Helpers/StatisticsHelper.cs index 76f048ad..4de4aecb 100644 --- a/ProjectLighthouse/Helpers/StatisticsHelper.cs +++ b/ProjectLighthouse/Helpers/StatisticsHelper.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Users; @@ -10,26 +11,26 @@ namespace LBPUnion.ProjectLighthouse.Helpers; public static class StatisticsHelper { - public static async Task RecentMatches(Database database) => await database.LastContacts.Where(l => TimeHelper.Timestamp - l.Timestamp < 300).CountAsync(); + public static async Task RecentMatches(DatabaseContext database) => await database.LastContacts.Where(l => TimeHelper.Timestamp - l.Timestamp < 300).CountAsync(); - public static async Task RecentMatchesForGame(Database database, GameVersion gameVersion) + public static async Task RecentMatchesForGame(DatabaseContext database, GameVersion gameVersion) => await database.LastContacts.Where(l => TimeHelper.Timestamp - l.Timestamp < 300 && l.GameVersion == gameVersion).CountAsync(); - public static async Task SlotCount(Database database) => await database.Slots.Where(s => s.Type == SlotType.User).CountAsync(); + public static async Task SlotCount(DatabaseContext database) => await database.Slots.Where(s => s.Type == SlotType.User).CountAsync(); - public static async Task SlotCountForGame(Database database, GameVersion gameVersion, bool includeSublevels = false) => await database.Slots.ByGameVersion(gameVersion, includeSublevels).CountAsync(); + public static async Task SlotCountForGame(DatabaseContext database, GameVersion gameVersion, bool includeSublevels = false) => await database.Slots.ByGameVersion(gameVersion, includeSublevels).CountAsync(); - public static async Task UserCount(Database database) => await database.Users.CountAsync(u => u.PermissionLevel != PermissionLevel.Banned); + public static async Task UserCount(DatabaseContext database) => await database.Users.CountAsync(u => u.PermissionLevel != PermissionLevel.Banned); - public static async Task TeamPickCount(Database database) => await database.Slots.CountAsync(s => s.TeamPick); + public static async Task TeamPickCount(DatabaseContext database) => await database.Slots.CountAsync(s => s.TeamPick); - public static async Task PhotoCount(Database database) => await database.Photos.CountAsync(); + public static async Task PhotoCount(DatabaseContext database) => await database.Photos.CountAsync(); #region Moderator/Admin specific - public static async Task ReportCount(Database database) => await database.Reports.CountAsync(); - public static async Task CaseCount(Database database) => await database.Cases.CountAsync(); - public static async Task DismissedCaseCount(Database database) => await database.Cases.CountAsync(c => c.DismissedAt != null); + public static async Task ReportCount(DatabaseContext database) => await database.Reports.CountAsync(); + public static async Task CaseCount(DatabaseContext database) => await database.Cases.CountAsync(); + public static async Task DismissedCaseCount(DatabaseContext database) => await database.Cases.CountAsync(c => c.DismissedAt != null); #endregion - public static async Task ApiKeyCount(Database database) => await database.APIKeys.CountAsync(); + public static async Task ApiKeyCount(DatabaseContext database) => await database.APIKeys.CountAsync(); } \ No newline at end of file diff --git a/ProjectLighthouse/Middlewares/MiddlewareDBContext.cs b/ProjectLighthouse/Middlewares/MiddlewareDBContext.cs index 77de227c..c0ca8a9b 100644 --- a/ProjectLighthouse/Middlewares/MiddlewareDBContext.cs +++ b/ProjectLighthouse/Middlewares/MiddlewareDBContext.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using JetBrains.Annotations; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.AspNetCore.Http; namespace LBPUnion.ProjectLighthouse.Middlewares; @@ -17,5 +18,5 @@ public abstract class MiddlewareDBContext } [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)] - public abstract Task InvokeAsync(HttpContext ctx, Database db); + public abstract Task InvokeAsync(HttpContext ctx, DatabaseContext db); } \ No newline at end of file diff --git a/ProjectLighthouse/Migrations/20211019021627_InitialCreate.cs b/ProjectLighthouse/Migrations/20211019021627_InitialCreate.cs index 0d74ff57..cd26fa79 100644 --- a/ProjectLighthouse/Migrations/20211019021627_InitialCreate.cs +++ b/ProjectLighthouse/Migrations/20211019021627_InitialCreate.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211019021627_InitialCreate")] public partial class InitialCreate : Migration { diff --git a/ProjectLighthouse/Migrations/20211019031221_HeartedLevels.cs b/ProjectLighthouse/Migrations/20211019031221_HeartedLevels.cs index f481f79d..9af9ae76 100644 --- a/ProjectLighthouse/Migrations/20211019031221_HeartedLevels.cs +++ b/ProjectLighthouse/Migrations/20211019031221_HeartedLevels.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211019031221_HeartedLevels")] public partial class HeartedLevels : Migration { diff --git a/ProjectLighthouse/Migrations/20211019203627_LastMatches.cs b/ProjectLighthouse/Migrations/20211019203627_LastMatches.cs index 58f834f1..90505c0d 100644 --- a/ProjectLighthouse/Migrations/20211019203627_LastMatches.cs +++ b/ProjectLighthouse/Migrations/20211019203627_LastMatches.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211019203627_LastMatches")] public partial class LastMatches : Migration { diff --git a/ProjectLighthouse/Migrations/20211020220840_ResourceList.cs b/ProjectLighthouse/Migrations/20211020220840_ResourceList.cs index 48f709a5..b52709b6 100644 --- a/ProjectLighthouse/Migrations/20211020220840_ResourceList.cs +++ b/ProjectLighthouse/Migrations/20211020220840_ResourceList.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211020220840_ResourceList")] public partial class ResourceList : Migration { diff --git a/ProjectLighthouse/Migrations/20211026010814_FavouriteUsers.cs b/ProjectLighthouse/Migrations/20211026010814_FavouriteUsers.cs index bd700421..2bfa7d53 100644 --- a/ProjectLighthouse/Migrations/20211026010814_FavouriteUsers.cs +++ b/ProjectLighthouse/Migrations/20211026010814_FavouriteUsers.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211026010814_FavouriteUsers")] public partial class FavouriteUsers : Migration { diff --git a/ProjectLighthouse/Migrations/20211028015915_AddSlotTimestamp.cs b/ProjectLighthouse/Migrations/20211028015915_AddSlotTimestamp.cs index 0ee069f9..ca0e1ebf 100644 --- a/ProjectLighthouse/Migrations/20211028015915_AddSlotTimestamp.cs +++ b/ProjectLighthouse/Migrations/20211028015915_AddSlotTimestamp.cs @@ -1,10 +1,11 @@ using LBPUnion.ProjectLighthouse.Helpers; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211028015915_AddSlotTimestamp")] public partial class AddSlotTimestamp : Migration { diff --git a/ProjectLighthouse/Migrations/20211028021513_AddSlotFirstUploadedAndLastUpdated.cs b/ProjectLighthouse/Migrations/20211028021513_AddSlotFirstUploadedAndLastUpdated.cs index a823ff60..1663e94e 100644 --- a/ProjectLighthouse/Migrations/20211028021513_AddSlotFirstUploadedAndLastUpdated.cs +++ b/ProjectLighthouse/Migrations/20211028021513_AddSlotFirstUploadedAndLastUpdated.cs @@ -1,10 +1,11 @@ using LBPUnion.ProjectLighthouse.Helpers; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211028021513_AddSlotFirstUploadedAndLastUpdated")] public partial class AddSlotFirstUploadedAndLastUpdated : Migration { diff --git a/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.cs b/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.cs index 552eac5d..11b1cb4f 100644 --- a/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.cs +++ b/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211029213334_RemoveUsedSlotsFromDb")] public partial class RemoveUsedSlotsFromDb : Migration { diff --git a/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.cs b/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.cs index c7f8bb05..a0da75c9 100644 --- a/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.cs +++ b/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211030203837_AddMMPickToSlot")] public partial class AddMMPickToSlot : Migration { diff --git a/ProjectLighthouse/Migrations/20211031234245_AddScoresTable.cs b/ProjectLighthouse/Migrations/20211031234245_AddScoresTable.cs index a2788823..46dbb13e 100644 --- a/ProjectLighthouse/Migrations/20211031234245_AddScoresTable.cs +++ b/ProjectLighthouse/Migrations/20211031234245_AddScoresTable.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211031234245_AddScoresTable")] public partial class AddScoresTable : Migration { diff --git a/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.cs b/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.cs index 9a5b318c..41411ff6 100644 --- a/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.cs +++ b/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211102215859_RenameTeamPick")] public partial class RenameTeamPick : Migration { diff --git a/ProjectLighthouse/Migrations/20211103194917_RemoveStartupMigrations.cs b/ProjectLighthouse/Migrations/20211103194917_RemoveStartupMigrations.cs index 0c902f3f..6cb59828 100644 --- a/ProjectLighthouse/Migrations/20211103194917_RemoveStartupMigrations.cs +++ b/ProjectLighthouse/Migrations/20211103194917_RemoveStartupMigrations.cs @@ -1,10 +1,11 @@ using LBPUnion.ProjectLighthouse.Helpers; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211103194917_RemoveStartupMigrations")] public partial class RemoveStartupMigrations : Migration { diff --git a/ProjectLighthouse/Migrations/20211104031327_AddGameVersionToToken.cs b/ProjectLighthouse/Migrations/20211104031327_AddGameVersionToToken.cs index 3d161624..a5024d6d 100644 --- a/ProjectLighthouse/Migrations/20211104031327_AddGameVersionToToken.cs +++ b/ProjectLighthouse/Migrations/20211104031327_AddGameVersionToToken.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211104031327_AddGameVersionToToken")] public partial class AddGameVersionToToken : Migration { diff --git a/ProjectLighthouse/Migrations/20211104040509_AddGameVersionToSlots.cs b/ProjectLighthouse/Migrations/20211104040509_AddGameVersionToSlots.cs index cc5ff033..cb89e5cd 100644 --- a/ProjectLighthouse/Migrations/20211104040509_AddGameVersionToSlots.cs +++ b/ProjectLighthouse/Migrations/20211104040509_AddGameVersionToSlots.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211104040509_AddGameVersionToSlots")] public partial class AddGameVersionToSlots : Migration { diff --git a/ProjectLighthouse/Migrations/20211104195812_AddPhotoSupport.cs b/ProjectLighthouse/Migrations/20211104195812_AddPhotoSupport.cs index b3c8d79b..5c7941c0 100644 --- a/ProjectLighthouse/Migrations/20211104195812_AddPhotoSupport.cs +++ b/ProjectLighthouse/Migrations/20211104195812_AddPhotoSupport.cs @@ -1,11 +1,12 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211104195812_AddPhotoSupport")] public partial class AddPhotoSupport : Migration { diff --git a/ProjectLighthouse/Migrations/20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName.cs b/ProjectLighthouse/Migrations/20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName.cs index b37be629..b286cf45 100644 --- a/ProjectLighthouse/Migrations/20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName.cs +++ b/ProjectLighthouse/Migrations/20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName")] public partial class UpdatePhotoAndPhotoSubjectToDoStuffWeirdName : Migration { diff --git a/ProjectLighthouse/Migrations/20211105205239_DropPhotoSubjectParentPhoto.cs b/ProjectLighthouse/Migrations/20211105205239_DropPhotoSubjectParentPhoto.cs index 03581a69..b634ef00 100644 --- a/ProjectLighthouse/Migrations/20211105205239_DropPhotoSubjectParentPhoto.cs +++ b/ProjectLighthouse/Migrations/20211105205239_DropPhotoSubjectParentPhoto.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211105205239_DropPhotoSubjectParentPhoto")] public partial class DropPhotoSubjectParentPhoto : Migration { diff --git a/ProjectLighthouse/Migrations/20211105205749_DropPhotoSlot.cs b/ProjectLighthouse/Migrations/20211105205749_DropPhotoSlot.cs index f36626c3..5a832e69 100644 --- a/ProjectLighthouse/Migrations/20211105205749_DropPhotoSlot.cs +++ b/ProjectLighthouse/Migrations/20211105205749_DropPhotoSlot.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211105205749_DropPhotoSlot")] public partial class DropPhotoSlot : Migration { diff --git a/ProjectLighthouse/Migrations/20211106010424_AddCreatorToPhoto.cs b/ProjectLighthouse/Migrations/20211106010424_AddCreatorToPhoto.cs index 938f3872..53d78d31 100644 --- a/ProjectLighthouse/Migrations/20211106010424_AddCreatorToPhoto.cs +++ b/ProjectLighthouse/Migrations/20211106010424_AddCreatorToPhoto.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211106010424_AddCreatorToPhoto")] public partial class AddCreatorToPhoto : Migration { diff --git a/ProjectLighthouse/Migrations/20211107023452_NoPhotosByMeOrWithMeInUser.cs b/ProjectLighthouse/Migrations/20211107023452_NoPhotosByMeOrWithMeInUser.cs index 9ba5b4c4..4a4a9c76 100644 --- a/ProjectLighthouse/Migrations/20211107023452_NoPhotosByMeOrWithMeInUser.cs +++ b/ProjectLighthouse/Migrations/20211107023452_NoPhotosByMeOrWithMeInUser.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211107023452_NoPhotosByMeOrWithMeInUser")] public partial class NoPhotosByMeOrWithMeInUser : Migration { diff --git a/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.cs b/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.cs index 4bf8951e..414ce3ac 100644 --- a/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.cs +++ b/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211108013443_RemoveCommentsEnabled")] public partial class RemoveCommentsEnabled : Migration { diff --git a/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.cs b/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.cs index e3988fc1..4b24ecc5 100644 --- a/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.cs +++ b/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211108015422_AddPlaysToSlot")] public partial class AddPlaysToSlot : Migration { diff --git a/ProjectLighthouse/Migrations/20211108054552_RemoveCountsFromDatabase.cs b/ProjectLighthouse/Migrations/20211108054552_RemoveCountsFromDatabase.cs index 9370ace3..25525303 100644 --- a/ProjectLighthouse/Migrations/20211108054552_RemoveCountsFromDatabase.cs +++ b/ProjectLighthouse/Migrations/20211108054552_RemoveCountsFromDatabase.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211108054552_RemoveCountsFromDatabase")] public partial class RemoveCountsFromDatabase : Migration { diff --git a/ProjectLighthouse/Migrations/20211108093616_GameSpecificPlayCounts.cs b/ProjectLighthouse/Migrations/20211108093616_GameSpecificPlayCounts.cs index 0c8a9de8..c9c90553 100644 --- a/ProjectLighthouse/Migrations/20211108093616_GameSpecificPlayCounts.cs +++ b/ProjectLighthouse/Migrations/20211108093616_GameSpecificPlayCounts.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211108093616_GameSpecificPlayCounts")] public partial class GameSpecificPlayCounts : Migration { diff --git a/ProjectLighthouse/Migrations/20211108114052_VisitedLevelsTable.cs b/ProjectLighthouse/Migrations/20211108114052_VisitedLevelsTable.cs index d08ae756..c226190a 100644 --- a/ProjectLighthouse/Migrations/20211108114052_VisitedLevelsTable.cs +++ b/ProjectLighthouse/Migrations/20211108114052_VisitedLevelsTable.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211108114052_VisitedLevelsTable")] public partial class VisitedLevelsTable : Migration { diff --git a/ProjectLighthouse/Migrations/20211108212022_BooYayRateLevels.cs b/ProjectLighthouse/Migrations/20211108212022_BooYayRateLevels.cs index 9ea17eff..c8ca0492 100644 --- a/ProjectLighthouse/Migrations/20211108212022_BooYayRateLevels.cs +++ b/ProjectLighthouse/Migrations/20211108212022_BooYayRateLevels.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211108212022_BooYayRateLevels")] public partial class BooYayRateLevels : Migration { diff --git a/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.cs b/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.cs index 38b355f7..cfd7b292 100644 --- a/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.cs +++ b/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211109225543_AddLevelTypeToSlot")] public partial class AddLevelTypeToSlot : Migration { diff --git a/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.cs b/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.cs index 7d94252a..95a00e72 100644 --- a/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.cs +++ b/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211113091631_AddUserLocationToToken")] public partial class AddUserLocationToToken : Migration { diff --git a/ProjectLighthouse/Migrations/20211113215128_VisitedLevelPlayCounts.cs b/ProjectLighthouse/Migrations/20211113215128_VisitedLevelPlayCounts.cs index c4780c6c..bca81f20 100644 --- a/ProjectLighthouse/Migrations/20211113215128_VisitedLevelPlayCounts.cs +++ b/ProjectLighthouse/Migrations/20211113215128_VisitedLevelPlayCounts.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211113215128_VisitedLevelPlayCounts")] public partial class VisitedLevelPlayCounts : Migration { diff --git a/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.cs b/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.cs index 16b6cf50..97d72d10 100644 --- a/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.cs +++ b/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211113220306_VisitedLevelDropGameVersion")] public partial class VisitedLevelDropGameVersion : Migration { diff --git a/ProjectLighthouse/Migrations/20211114231343_UserRefactor.cs b/ProjectLighthouse/Migrations/20211114231343_UserRefactor.cs index f15d6f8e..b31938c3 100644 --- a/ProjectLighthouse/Migrations/20211114231343_UserRefactor.cs +++ b/ProjectLighthouse/Migrations/20211114231343_UserRefactor.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211114231343_UserRefactor")] public partial class UserRefactor : Migration { diff --git a/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.cs b/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.cs index e4e4a7fd..75fb7786 100644 --- a/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.cs +++ b/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.cs @@ -1,11 +1,12 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211115050553_UserAddDefaultsToNullableStrings")] public partial class UserAddDefaultsToNullableStrings : Migration { diff --git a/ProjectLighthouse/Migrations/20211115052941_SlotAddLbpVitaPlays.cs b/ProjectLighthouse/Migrations/20211115052941_SlotAddLbpVitaPlays.cs index f152359d..015b8084 100644 --- a/ProjectLighthouse/Migrations/20211115052941_SlotAddLbpVitaPlays.cs +++ b/ProjectLighthouse/Migrations/20211115052941_SlotAddLbpVitaPlays.cs @@ -1,12 +1,13 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211115052941_SlotAddLbpVitaPlays")] public partial class SlotAddLbpVitaPlays : Migration { diff --git a/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.cs b/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.cs index b9a57db4..a0bc8a06 100644 --- a/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.cs +++ b/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.cs @@ -1,12 +1,13 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211120045239_AddPasswordToUser")] public partial class AddPasswordToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.cs b/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.cs index ed97f400..729c1e2d 100644 --- a/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.cs +++ b/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.cs @@ -1,12 +1,13 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211120052549_RenameTokensToGameTokens")] public partial class RenameTokensToGameTokens : Migration { diff --git a/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.cs b/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.cs index e1ed7157..a3cebd84 100644 --- a/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.cs +++ b/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.cs @@ -1,13 +1,14 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211120053654_AddWebTokens")] public partial class AddWebTokens : Migration { diff --git a/ProjectLighthouse/Migrations/20211122002000_AddAuthenticationAttempts.cs b/ProjectLighthouse/Migrations/20211122002000_AddAuthenticationAttempts.cs index bcee6953..1f0d4589 100644 --- a/ProjectLighthouse/Migrations/20211122002000_AddAuthenticationAttempts.cs +++ b/ProjectLighthouse/Migrations/20211122002000_AddAuthenticationAttempts.cs @@ -1,13 +1,14 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211122002000_AddAuthenticationAttempts")] public partial class AddAuthenticationAttempts : Migration { diff --git a/ProjectLighthouse/Migrations/20211123224001_AddIsAdminToUser.cs b/ProjectLighthouse/Migrations/20211123224001_AddIsAdminToUser.cs index ccfdc18e..41d5dfb8 100644 --- a/ProjectLighthouse/Migrations/20211123224001_AddIsAdminToUser.cs +++ b/ProjectLighthouse/Migrations/20211123224001_AddIsAdminToUser.cs @@ -1,12 +1,13 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211123224001_AddIsAdminToUser")] public partial class AddIsAdminToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20211125052035_AddGameVersionToLastMatch.cs b/ProjectLighthouse/Migrations/20211125052035_AddGameVersionToLastMatch.cs index 2d1dcc24..2991a065 100644 --- a/ProjectLighthouse/Migrations/20211125052035_AddGameVersionToLastMatch.cs +++ b/ProjectLighthouse/Migrations/20211125052035_AddGameVersionToLastMatch.cs @@ -1,12 +1,13 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211125052035_AddGameVersionToLastMatch")] public partial class AddGameVersionToLastMatch : Migration { diff --git a/ProjectLighthouse/Migrations/20211127201738_AddPasswordResetRequiredToUser.cs b/ProjectLighthouse/Migrations/20211127201738_AddPasswordResetRequiredToUser.cs index 91e422fd..37a801d8 100644 --- a/ProjectLighthouse/Migrations/20211127201738_AddPasswordResetRequiredToUser.cs +++ b/ProjectLighthouse/Migrations/20211127201738_AddPasswordResetRequiredToUser.cs @@ -1,12 +1,13 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211127201738_AddPasswordResetRequiredToUser")] public partial class AddPasswordResetRequiredToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20211130190200_AddYayBooMehHashesToUser.cs b/ProjectLighthouse/Migrations/20211130190200_AddYayBooMehHashesToUser.cs index 3253a3fd..ccdbc767 100644 --- a/ProjectLighthouse/Migrations/20211130190200_AddYayBooMehHashesToUser.cs +++ b/ProjectLighthouse/Migrations/20211130190200_AddYayBooMehHashesToUser.cs @@ -1,12 +1,13 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211130190200_AddYayBooMehHashesToUser")] public partial class AddYayBooMehHashesToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20211202235932_RenameLastMatchesToLastContacts.cs b/ProjectLighthouse/Migrations/20211202235932_RenameLastMatchesToLastContacts.cs index 645b430b..3a0fe545 100644 --- a/ProjectLighthouse/Migrations/20211202235932_RenameLastMatchesToLastContacts.cs +++ b/ProjectLighthouse/Migrations/20211202235932_RenameLastMatchesToLastContacts.cs @@ -1,13 +1,14 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211202235932_RenameLastMatchesToLastContacts")] public partial class RenameLastMatchesToLastContacts : Migration { diff --git a/ProjectLighthouse/Migrations/20211211045823_AddLevelReviews.cs b/ProjectLighthouse/Migrations/20211211045823_AddLevelReviews.cs index b808a597..16c755e8 100644 --- a/ProjectLighthouse/Migrations/20211211045823_AddLevelReviews.cs +++ b/ProjectLighthouse/Migrations/20211211045823_AddLevelReviews.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211211045823_AddLevelReviews")] public partial class AddLevelReviews : Migration { diff --git a/ProjectLighthouse/Migrations/20211213195540_AddUserApprovedIpAddresses.cs b/ProjectLighthouse/Migrations/20211213195540_AddUserApprovedIpAddresses.cs index 4f9264df..bd165a8c 100644 --- a/ProjectLighthouse/Migrations/20211213195540_AddUserApprovedIpAddresses.cs +++ b/ProjectLighthouse/Migrations/20211213195540_AddUserApprovedIpAddresses.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211213195540_AddUserApprovedIpAddresses")] public partial class AddUserApprovedIpAddresses : Migration { diff --git a/ProjectLighthouse/Migrations/20211214005427_AddUsedBoolToGameToken.cs b/ProjectLighthouse/Migrations/20211214005427_AddUsedBoolToGameToken.cs index 359a10ef..957e8455 100644 --- a/ProjectLighthouse/Migrations/20211214005427_AddUsedBoolToGameToken.cs +++ b/ProjectLighthouse/Migrations/20211214005427_AddUsedBoolToGameToken.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211214005427_AddUsedBoolToGameToken")] public partial class AddUsedBoolToGameToken : Migration { diff --git a/ProjectLighthouse/Migrations/20211217000749_AddBannedPropertiesToUser.cs b/ProjectLighthouse/Migrations/20211217000749_AddBannedPropertiesToUser.cs index 6f2f5a64..a67d39e9 100644 --- a/ProjectLighthouse/Migrations/20211217000749_AddBannedPropertiesToUser.cs +++ b/ProjectLighthouse/Migrations/20211217000749_AddBannedPropertiesToUser.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20211217000749_AddBannedPropertiesToUser")] public partial class AddBannedPropertiesToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20220113125615_AddDatabaseCustomCategories.cs b/ProjectLighthouse/Migrations/20220113125615_AddDatabaseCustomCategories.cs index b7b06c3e..d15ce597 100644 --- a/ProjectLighthouse/Migrations/20220113125615_AddDatabaseCustomCategories.cs +++ b/ProjectLighthouse/Migrations/20220113125615_AddDatabaseCustomCategories.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220113125615_AddDatabaseCustomCategories")] public partial class AddDatabaseCustomCategories : Migration { diff --git a/ProjectLighthouse/Migrations/20220121024607_AddVitaCrossControlRequiredToSlot.cs b/ProjectLighthouse/Migrations/20220121024607_AddVitaCrossControlRequiredToSlot.cs index 107c2780..f5aa590c 100644 --- a/ProjectLighthouse/Migrations/20220121024607_AddVitaCrossControlRequiredToSlot.cs +++ b/ProjectLighthouse/Migrations/20220121024607_AddVitaCrossControlRequiredToSlot.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220121024607_AddVitaCrossControlRequiredToSlot")] public partial class AddVitaCrossControlRequiredToSlot : Migration { diff --git a/ProjectLighthouse/Migrations/20220205132152_CommentRefactor.cs b/ProjectLighthouse/Migrations/20220205132152_CommentRefactor.cs index bd829b58..c20c093f 100644 --- a/ProjectLighthouse/Migrations/20220205132152_CommentRefactor.cs +++ b/ProjectLighthouse/Migrations/20220205132152_CommentRefactor.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220205132152_CommentRefactor")] public partial class CommentRefactor : Migration { diff --git a/ProjectLighthouse/Migrations/20220212041106_AddGriefReports.cs b/ProjectLighthouse/Migrations/20220212041106_AddGriefReports.cs index 1e2db007..b34bfee2 100644 --- a/ProjectLighthouse/Migrations/20220212041106_AddGriefReports.cs +++ b/ProjectLighthouse/Migrations/20220212041106_AddGriefReports.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220212041106_AddGriefReports")] public partial class AddGriefReports : Migration { diff --git a/ProjectLighthouse/Migrations/20220212091645_RemoveVisiblePlayersFromReport.cs b/ProjectLighthouse/Migrations/20220212091645_RemoveVisiblePlayersFromReport.cs index 220ef994..d48d0c3b 100644 --- a/ProjectLighthouse/Migrations/20220212091645_RemoveVisiblePlayersFromReport.cs +++ b/ProjectLighthouse/Migrations/20220212091645_RemoveVisiblePlayersFromReport.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220212091645_RemoveVisiblePlayersFromReport")] public partial class RemoveVisiblePlayersFromReport : Migration { diff --git a/ProjectLighthouse/Migrations/20220216230824_AddEarthHashesForAllGames.cs b/ProjectLighthouse/Migrations/20220216230824_AddEarthHashesForAllGames.cs index d44d08fa..ae777834 100644 --- a/ProjectLighthouse/Migrations/20220216230824_AddEarthHashesForAllGames.cs +++ b/ProjectLighthouse/Migrations/20220216230824_AddEarthHashesForAllGames.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220216230824_AddEarthHashesForAllGames")] public partial class AddEarthHashesForAllGames : Migration { diff --git a/ProjectLighthouse/Migrations/20220217045519_AddPlatformForLastContactsAndGameTokens.cs b/ProjectLighthouse/Migrations/20220217045519_AddPlatformForLastContactsAndGameTokens.cs index 78342cfe..bf08a221 100644 --- a/ProjectLighthouse/Migrations/20220217045519_AddPlatformForLastContactsAndGameTokens.cs +++ b/ProjectLighthouse/Migrations/20220217045519_AddPlatformForLastContactsAndGameTokens.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220217045519_AddPlatformForLastContactsAndGameTokens")] public partial class AddPlatformForLastContactsAndGameTokens : Migration { diff --git a/ProjectLighthouse/Migrations/20220301195426_AddEmailAddressToUser.cs b/ProjectLighthouse/Migrations/20220301195426_AddEmailAddressToUser.cs index d466c49d..84dfdd23 100644 --- a/ProjectLighthouse/Migrations/20220301195426_AddEmailAddressToUser.cs +++ b/ProjectLighthouse/Migrations/20220301195426_AddEmailAddressToUser.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220301195426_AddEmailAddressToUser")] public partial class AddEmailAddressToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20220301204930_AddEmailVerificationTokens.cs b/ProjectLighthouse/Migrations/20220301204930_AddEmailVerificationTokens.cs index fb9b1541..b8c867a9 100644 --- a/ProjectLighthouse/Migrations/20220301204930_AddEmailVerificationTokens.cs +++ b/ProjectLighthouse/Migrations/20220301204930_AddEmailVerificationTokens.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220301204930_AddEmailVerificationTokens")] public partial class AddEmailVerificationTokens : Migration { diff --git a/ProjectLighthouse/Migrations/20220301212120_SplitSetAndVerificationTokenTypes.cs b/ProjectLighthouse/Migrations/20220301212120_SplitSetAndVerificationTokenTypes.cs index 69619618..4c71e640 100644 --- a/ProjectLighthouse/Migrations/20220301212120_SplitSetAndVerificationTokenTypes.cs +++ b/ProjectLighthouse/Migrations/20220301212120_SplitSetAndVerificationTokenTypes.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220301212120_SplitSetAndVerificationTokenTypes")] public partial class SplitSetAndVerificationTokenTypes : Migration { diff --git a/ProjectLighthouse/Migrations/20220302003658_AddEmailVerifiedToUser.cs b/ProjectLighthouse/Migrations/20220302003658_AddEmailVerifiedToUser.cs index 0a7e595c..873e10ab 100644 --- a/ProjectLighthouse/Migrations/20220302003658_AddEmailVerifiedToUser.cs +++ b/ProjectLighthouse/Migrations/20220302003658_AddEmailVerifiedToUser.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220302003658_AddEmailVerifiedToUser")] public partial class AddEmailVerifiedToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20220402212909_AddAdminGrantedSlotsToUser.cs b/ProjectLighthouse/Migrations/20220402212909_AddAdminGrantedSlotsToUser.cs index ade2135e..4c1764cf 100644 --- a/ProjectLighthouse/Migrations/20220402212909_AddAdminGrantedSlotsToUser.cs +++ b/ProjectLighthouse/Migrations/20220402212909_AddAdminGrantedSlotsToUser.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220402212909_AddAdminGrantedSlotsToUser")] public partial class AddAdminGrantedSlotsToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20220413192851_AddUserForeignKeyToLastContacts.cs b/ProjectLighthouse/Migrations/20220413192851_AddUserForeignKeyToLastContacts.cs index 08951789..901b56c1 100644 --- a/ProjectLighthouse/Migrations/20220413192851_AddUserForeignKeyToLastContacts.cs +++ b/ProjectLighthouse/Migrations/20220413192851_AddUserForeignKeyToLastContacts.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -9,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220413192851_AddUserForeignKeyToLastContacts")] public partial class AddUserForeignKeyToLastContacts : Migration { diff --git a/ProjectLighthouse/Migrations/20220522192158_SwitchToPermissionLevels.cs b/ProjectLighthouse/Migrations/20220522192158_SwitchToPermissionLevels.cs index df995542..1733aaf2 100644 --- a/ProjectLighthouse/Migrations/20220522192158_SwitchToPermissionLevels.cs +++ b/ProjectLighthouse/Migrations/20220522192158_SwitchToPermissionLevels.cs @@ -3,12 +3,13 @@ #nullable disable using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220522192158_SwitchToPermissionLevels")] public class SwitchToPermissionLevels : Migration { diff --git a/ProjectLighthouse/Migrations/20220610061641_AddCompletedMigrations.cs b/ProjectLighthouse/Migrations/20220610061641_AddCompletedMigrations.cs index 5c33f89a..eb2c9297 100644 --- a/ProjectLighthouse/Migrations/20220610061641_AddCompletedMigrations.cs +++ b/ProjectLighthouse/Migrations/20220610061641_AddCompletedMigrations.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220610061641_AddCompletedMigrations")] public class AddCompletedMigrations : Migration { diff --git a/ProjectLighthouse/Migrations/20220610230341_AddModerationCases.cs b/ProjectLighthouse/Migrations/20220610230341_AddModerationCases.cs index 5f98544d..336549b8 100644 --- a/ProjectLighthouse/Migrations/20220610230341_AddModerationCases.cs +++ b/ProjectLighthouse/Migrations/20220610230341_AddModerationCases.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -8,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220610230341_AddModerationCases")] public class AddModerationCases : Migration { diff --git a/ProjectLighthouse/Migrations/20220610230647_AddExpirationDateToCases.cs b/ProjectLighthouse/Migrations/20220610230647_AddExpirationDateToCases.cs index 95a25330..d19edd98 100644 --- a/ProjectLighthouse/Migrations/20220610230647_AddExpirationDateToCases.cs +++ b/ProjectLighthouse/Migrations/20220610230647_AddExpirationDateToCases.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220610230647_AddExpirationDateToCases")] public class AddExpirationDateToCases : Migration { diff --git a/ProjectLighthouse/Migrations/20220611012037_AddAffectedIdToCases.cs b/ProjectLighthouse/Migrations/20220611012037_AddAffectedIdToCases.cs index 4f906d80..ca19e108 100644 --- a/ProjectLighthouse/Migrations/20220611012037_AddAffectedIdToCases.cs +++ b/ProjectLighthouse/Migrations/20220611012037_AddAffectedIdToCases.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220611012037_AddAffectedIdToCases")] public class AddAffectedIdToCases : Migration { diff --git a/ProjectLighthouse/Migrations/20220611221819_OnlyAllowSingleApprovedIP.cs b/ProjectLighthouse/Migrations/20220611221819_OnlyAllowSingleApprovedIP.cs index 8e03d50d..1d4ea508 100644 --- a/ProjectLighthouse/Migrations/20220611221819_OnlyAllowSingleApprovedIP.cs +++ b/ProjectLighthouse/Migrations/20220611221819_OnlyAllowSingleApprovedIP.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220611221819_OnlyAllowSingleApprovedIP")] public class OnlyAllowSingleApprovedIP : Migration { diff --git a/ProjectLighthouse/Migrations/20220624210701_AddedPasswordResetTokens.cs b/ProjectLighthouse/Migrations/20220624210701_AddedPasswordResetTokens.cs index 35a27a01..049983c1 100644 --- a/ProjectLighthouse/Migrations/20220624210701_AddedPasswordResetTokens.cs +++ b/ProjectLighthouse/Migrations/20220624210701_AddedPasswordResetTokens.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -8,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220624210701_AddedPasswordResetTokens")] public partial class AddedPasswordResetTokens : Migration { diff --git a/ProjectLighthouse/Migrations/20220715222906_UserInvite.cs b/ProjectLighthouse/Migrations/20220715222906_UserInvite.cs index 98312088..5b30385a 100644 --- a/ProjectLighthouse/Migrations/20220715222906_UserInvite.cs +++ b/ProjectLighthouse/Migrations/20220715222906_UserInvite.cs @@ -3,12 +3,13 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Infrastructure; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220715222906_UserInvite")] public partial class UserInvite : Migration { diff --git a/ProjectLighthouse/Migrations/20220716234844_RemovedAPIKeyEnabled.cs b/ProjectLighthouse/Migrations/20220716234844_RemovedAPIKeyEnabled.cs index fc3f2ee1..f2b2f7de 100644 --- a/ProjectLighthouse/Migrations/20220716234844_RemovedAPIKeyEnabled.cs +++ b/ProjectLighthouse/Migrations/20220716234844_RemovedAPIKeyEnabled.cs @@ -1,11 +1,12 @@ using Microsoft.EntityFrameworkCore.Migrations; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; #nullable disable namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220716234844_RemovedAPIKeyEnabled")] public partial class RemovedAPIKeyEnabled : Migration { diff --git a/ProjectLighthouse/Migrations/20220729002704_DeveloperSlots.cs b/ProjectLighthouse/Migrations/20220729002704_DeveloperSlots.cs index d05747f6..8a065177 100644 --- a/ProjectLighthouse/Migrations/20220729002704_DeveloperSlots.cs +++ b/ProjectLighthouse/Migrations/20220729002704_DeveloperSlots.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220729002704_DeveloperSlots")] public partial class DeveloperSlots : Migration { diff --git a/ProjectLighthouse/Migrations/20220729182709_AddExpiryTimesToTokens.cs b/ProjectLighthouse/Migrations/20220729182709_AddExpiryTimesToTokens.cs index 1560ad99..784f3aab 100644 --- a/ProjectLighthouse/Migrations/20220729182709_AddExpiryTimesToTokens.cs +++ b/ProjectLighthouse/Migrations/20220729182709_AddExpiryTimesToTokens.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220729182709_AddExpiryTimesToTokens")] public partial class AddExpiryTimesToTokens : Migration { diff --git a/ProjectLighthouse/Migrations/20220801055525_AddPrivacySettingsToUser.cs b/ProjectLighthouse/Migrations/20220801055525_AddPrivacySettingsToUser.cs index d0735a73..4fca5c5c 100644 --- a/ProjectLighthouse/Migrations/20220801055525_AddPrivacySettingsToUser.cs +++ b/ProjectLighthouse/Migrations/20220801055525_AddPrivacySettingsToUser.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220801055525_AddPrivacySettingsToUser")] public partial class AddPrivacySettingsToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs b/ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs index 43659add..f73cb4f6 100644 --- a/ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs +++ b/ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220802150408_Arrrrrr")] public partial class Arrrrrr : Migration { diff --git a/ProjectLighthouse/Migrations/20220805213150_RenameCaseProperties.cs b/ProjectLighthouse/Migrations/20220805213150_RenameCaseProperties.cs index 73e9fd79..89bcc995 100644 --- a/ProjectLighthouse/Migrations/20220805213150_RenameCaseProperties.cs +++ b/ProjectLighthouse/Migrations/20220805213150_RenameCaseProperties.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220805213150_RenameCaseProperties")] public partial class RenameCaseProperties : Migration { diff --git a/ProjectLighthouse/Migrations/20220805234507_AddModNotesToCase.cs b/ProjectLighthouse/Migrations/20220805234507_AddModNotesToCase.cs index 44cc6953..20b5aca4 100644 --- a/ProjectLighthouse/Migrations/20220805234507_AddModNotesToCase.cs +++ b/ProjectLighthouse/Migrations/20220805234507_AddModNotesToCase.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220805234507_AddModNotesToCase")] public partial class AddModNotesToCase : Migration { diff --git a/ProjectLighthouse/Migrations/20220806013840_AddHiddenSlots.cs b/ProjectLighthouse/Migrations/20220806013840_AddHiddenSlots.cs index 68e16ea7..3e3a0ed5 100644 --- a/ProjectLighthouse/Migrations/20220806013840_AddHiddenSlots.cs +++ b/ProjectLighthouse/Migrations/20220806013840_AddHiddenSlots.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220806013840_AddHiddenSlots")] public partial class AddHiddenSlots : Migration { diff --git a/ProjectLighthouse/Migrations/20220806181028_AddCommentsEnabledToSlotsAndUsers.cs b/ProjectLighthouse/Migrations/20220806181028_AddCommentsEnabledToSlotsAndUsers.cs index baeb4401..f2b96349 100644 --- a/ProjectLighthouse/Migrations/20220806181028_AddCommentsEnabledToSlotsAndUsers.cs +++ b/ProjectLighthouse/Migrations/20220806181028_AddCommentsEnabledToSlotsAndUsers.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220806181028_AddCommentsEnabledToSlotsAndUsers")] public partial class AddCommentsEnabledToSlotsAndUsers : Migration { diff --git a/ProjectLighthouse/Migrations/20220808053519_RemoveVitaPlayCount.cs b/ProjectLighthouse/Migrations/20220808053519_RemoveVitaPlayCount.cs index cdc0fb2b..0518b5bf 100644 --- a/ProjectLighthouse/Migrations/20220808053519_RemoveVitaPlayCount.cs +++ b/ProjectLighthouse/Migrations/20220808053519_RemoveVitaPlayCount.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220808053519_RemoveVitaPlayCount")] public partial class RemoveVitaPlayCount : Migration { diff --git a/ProjectLighthouse/Migrations/20220825212051_AddLevelTagToRatedLevel.cs b/ProjectLighthouse/Migrations/20220825212051_AddLevelTagToRatedLevel.cs index 988ad314..a0dac008 100644 --- a/ProjectLighthouse/Migrations/20220825212051_AddLevelTagToRatedLevel.cs +++ b/ProjectLighthouse/Migrations/20220825212051_AddLevelTagToRatedLevel.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220825212051_AddLevelTagToRatedLevel")] public partial class AddLevelTagToRatedLevel : Migration { diff --git a/ProjectLighthouse/Migrations/20220826001101_AddLoginTimestampsToUser.cs b/ProjectLighthouse/Migrations/20220826001101_AddLoginTimestampsToUser.cs index 9064564c..879c9037 100644 --- a/ProjectLighthouse/Migrations/20220826001101_AddLoginTimestampsToUser.cs +++ b/ProjectLighthouse/Migrations/20220826001101_AddLoginTimestampsToUser.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220826001101_AddLoginTimestampsToUser")] public partial class AddLoginTimestampsToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20220910190711_AddUserLanguageAndTimezone.cs b/ProjectLighthouse/Migrations/20220910190711_AddUserLanguageAndTimezone.cs index a574128a..4585feb8 100644 --- a/ProjectLighthouse/Migrations/20220910190711_AddUserLanguageAndTimezone.cs +++ b/ProjectLighthouse/Migrations/20220910190711_AddUserLanguageAndTimezone.cs @@ -1,5 +1,6 @@ using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -8,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220910190711_AddUserLanguageAndTimezone")] public partial class AddUserLanguageAndTimezone : Migration { diff --git a/ProjectLighthouse/Migrations/20220910190824_RemoveUserIsAPirate.cs b/ProjectLighthouse/Migrations/20220910190824_RemoveUserIsAPirate.cs index 11f81031..ae49d2dc 100644 --- a/ProjectLighthouse/Migrations/20220910190824_RemoveUserIsAPirate.cs +++ b/ProjectLighthouse/Migrations/20220910190824_RemoveUserIsAPirate.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220910190824_RemoveUserIsAPirate")] public partial class RemoveUserIsAPirate : Migration { diff --git a/ProjectLighthouse/Migrations/20220916141401_ScoreboardAdvSlot.cs b/ProjectLighthouse/Migrations/20220916141401_ScoreboardAdvSlot.cs index 9c5cb567..7b81833b 100644 --- a/ProjectLighthouse/Migrations/20220916141401_ScoreboardAdvSlot.cs +++ b/ProjectLighthouse/Migrations/20220916141401_ScoreboardAdvSlot.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220916141401_ScoreboardAdvSlot")] public partial class CreateScoreboardAdvSlot : Migration { diff --git a/ProjectLighthouse/Migrations/20220918154500_AddIsAdventureColumn.cs b/ProjectLighthouse/Migrations/20220918154500_AddIsAdventureColumn.cs index aecbffb1..cdb4816e 100644 --- a/ProjectLighthouse/Migrations/20220918154500_AddIsAdventureColumn.cs +++ b/ProjectLighthouse/Migrations/20220918154500_AddIsAdventureColumn.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220918154500_AddIsAdventureColumn")] public partial class AddisAdventureColumn : Migration { diff --git a/ProjectLighthouse/Migrations/20220923042831_AddPlaylists.cs b/ProjectLighthouse/Migrations/20220923042831_AddPlaylists.cs index f7023a6d..8677eecd 100644 --- a/ProjectLighthouse/Migrations/20220923042831_AddPlaylists.cs +++ b/ProjectLighthouse/Migrations/20220923042831_AddPlaylists.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20220923042831_AddPlaylists")] public partial class AddPlaylists : Migration { diff --git a/ProjectLighthouse/Migrations/20221016234831_AddUsernameToRegistrationToken.cs b/ProjectLighthouse/Migrations/20221016234831_AddUsernameToRegistrationToken.cs index e0acd22f..d34b4a36 100644 --- a/ProjectLighthouse/Migrations/20221016234831_AddUsernameToRegistrationToken.cs +++ b/ProjectLighthouse/Migrations/20221016234831_AddUsernameToRegistrationToken.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20221016234831_AddUsernameToRegistrationToken")] public partial class AddUsernameToRegistrationToken : Migration { diff --git a/ProjectLighthouse/Migrations/20221105212037_AddTwoFactorToUser.cs b/ProjectLighthouse/Migrations/20221105212037_AddTwoFactorToUser.cs index 5fc60425..e9967696 100644 --- a/ProjectLighthouse/Migrations/20221105212037_AddTwoFactorToUser.cs +++ b/ProjectLighthouse/Migrations/20221105212037_AddTwoFactorToUser.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20221105212037_AddTwoFactorToUser")] public partial class AddTwoFactorToUser : Migration { diff --git a/ProjectLighthouse/Migrations/20221117165700_AddCrossControlPlanet.cs b/ProjectLighthouse/Migrations/20221117165700_AddCrossControlPlanet.cs index 35cf872e..1aa97212 100644 --- a/ProjectLighthouse/Migrations/20221117165700_AddCrossControlPlanet.cs +++ b/ProjectLighthouse/Migrations/20221117165700_AddCrossControlPlanet.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20221117165700_AddCrossControlPlanet")] public partial class AddCrossControlPlanet : Migration { diff --git a/ProjectLighthouse/Migrations/20221118162114_AddVerifiedToWebToken.cs b/ProjectLighthouse/Migrations/20221118162114_AddVerifiedToWebToken.cs index edeb951b..391d221b 100644 --- a/ProjectLighthouse/Migrations/20221118162114_AddVerifiedToWebToken.cs +++ b/ProjectLighthouse/Migrations/20221118162114_AddVerifiedToWebToken.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20221118162114_AddVerifiedToWebToken")] public partial class AddVerifiedToWebToken : Migration { diff --git a/ProjectLighthouse/Migrations/20221217002014_ReworkGameTokens.cs b/ProjectLighthouse/Migrations/20221217002014_ReworkGameTokens.cs index abba900e..1a01cc53 100644 --- a/ProjectLighthouse/Migrations/20221217002014_ReworkGameTokens.cs +++ b/ProjectLighthouse/Migrations/20221217002014_ReworkGameTokens.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20221217002014_ReworkGameTokens")] public partial class ReworkGameTokens : Migration { diff --git a/ProjectLighthouse/Migrations/20221217043015_AddPlatformLinkAttempts.cs b/ProjectLighthouse/Migrations/20221217043015_AddPlatformLinkAttempts.cs index 2fd2ba51..c83454c5 100644 --- a/ProjectLighthouse/Migrations/20221217043015_AddPlatformLinkAttempts.cs +++ b/ProjectLighthouse/Migrations/20221217043015_AddPlatformLinkAttempts.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -7,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20221217043015_AddPlatformLinkAttempts")] public partial class AddPlatformLinkAttempts : Migration { diff --git a/ProjectLighthouse/Migrations/20221217044751_AddForeignKeyToLinkAttempts.cs b/ProjectLighthouse/Migrations/20221217044751_AddForeignKeyToLinkAttempts.cs index c7fbefbf..88888a6b 100644 --- a/ProjectLighthouse/Migrations/20221217044751_AddForeignKeyToLinkAttempts.cs +++ b/ProjectLighthouse/Migrations/20221217044751_AddForeignKeyToLinkAttempts.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20221217044751_AddForeignKeyToLinkAttempts")] public partial class AddForeignKeyToLinkAttempts : Migration { diff --git a/ProjectLighthouse/Migrations/20230127021453_AddUsernameToCaseTable.cs b/ProjectLighthouse/Migrations/20230127021453_AddUsernameToCaseTable.cs index 4ffff73f..301c3c4b 100644 --- a/ProjectLighthouse/Migrations/20230127021453_AddUsernameToCaseTable.cs +++ b/ProjectLighthouse/Migrations/20230127021453_AddUsernameToCaseTable.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -6,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20230127021453_AddUsernameToCaseTable")] public partial class AddUsernameToCaseTable : Migration { diff --git a/ProjectLighthouse/Migrations/20230208165011_AddedUserBlocking.cs b/ProjectLighthouse/Migrations/20230208165011_AddedUserBlocking.cs index bf942046..20d8ec57 100644 --- a/ProjectLighthouse/Migrations/20230208165011_AddedUserBlocking.cs +++ b/ProjectLighthouse/Migrations/20230208165011_AddedUserBlocking.cs @@ -1,4 +1,5 @@ using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -8,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] [Migration("20230208165011_AddedUserBlocking")] public partial class AddedUserBlocking : Migration { diff --git a/ProjectLighthouse/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs b/ProjectLighthouse/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs index 0353524e..ff0f0c1d 100644 --- a/ProjectLighthouse/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs +++ b/ProjectLighthouse/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs @@ -1,6 +1,7 @@ // using System; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Database; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -9,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ProjectLighthouse.Migrations { - [DbContext(typeof(Database))] + [DbContext(typeof(DatabaseContext))] partial class DatabaseModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) diff --git a/ProjectLighthouse/Serialization/LbpSerializer.cs b/ProjectLighthouse/Serialization/LbpSerializer.cs index 484d1306..6b687620 100644 --- a/ProjectLighthouse/Serialization/LbpSerializer.cs +++ b/ProjectLighthouse/Serialization/LbpSerializer.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; -using YamlDotNet.Core.Tokens; namespace LBPUnion.ProjectLighthouse.Serialization; diff --git a/ProjectLighthouse/StartupTasks.cs b/ProjectLighthouse/StartupTasks.cs index 965a412c..124b3e26 100644 --- a/ProjectLighthouse/StartupTasks.cs +++ b/ProjectLighthouse/StartupTasks.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using LBPUnion.ProjectLighthouse.Administration; using LBPUnion.ProjectLighthouse.Administration.Maintenance; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Helpers; @@ -63,7 +64,7 @@ public static class StartupTasks } if (!dbConnected) Environment.Exit(1); - using Database database = new(); + using DatabaseContext database = new(); migrateDatabase(database).Wait(); @@ -150,7 +151,7 @@ public static class StartupTasks return didLoad; } - private static async Task migrateDatabase(Database database) + private static async Task migrateDatabase(DatabaseContext database) { // This mutex is used to synchronize migrations across the GameServer, Website, and Api // Without it, each server would try to simultaneously migrate the database resulting in undefined behavior diff --git a/ProjectLighthouse/StorableLists/RedisStorableList.cs b/ProjectLighthouse/StorableLists/RedisStorableList.cs index 7bbc4c10..31ccb0db 100644 --- a/ProjectLighthouse/StorableLists/RedisStorableList.cs +++ b/ProjectLighthouse/StorableLists/RedisStorableList.cs @@ -1,4 +1,3 @@ -using System; using System.Threading.Tasks; using Redis.OM.Searching; diff --git a/ProjectLighthouse/Tickets/NPTicket.cs b/ProjectLighthouse/Tickets/NPTicket.cs index fe6e17ae..3837606d 100644 --- a/ProjectLighthouse/Tickets/NPTicket.cs +++ b/ProjectLighthouse/Tickets/NPTicket.cs @@ -17,7 +17,6 @@ using Org.BouncyCastle.Math; using Org.BouncyCastle.Math.EC; using Org.BouncyCastle.Security; #if DEBUG -using System.Text; using System.Text.Json; #endif diff --git a/ProjectLighthouse/Tickets/TicketReader.cs b/ProjectLighthouse/Tickets/TicketReader.cs index c13f37bf..b2a4dde9 100644 --- a/ProjectLighthouse/Tickets/TicketReader.cs +++ b/ProjectLighthouse/Tickets/TicketReader.cs @@ -3,7 +3,6 @@ using System.IO; using System.Text; using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Extensions; -using LBPUnion.ProjectLighthouse.Types.Misc; namespace LBPUnion.ProjectLighthouse.Tickets; diff --git a/ProjectLighthouse/Types/Entities/Level/Playlist.cs b/ProjectLighthouse/Types/Entities/Level/Playlist.cs index fbe68c3a..dcd6c127 100644 --- a/ProjectLighthouse/Types/Entities/Level/Playlist.cs +++ b/ProjectLighthouse/Types/Entities/Level/Playlist.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text.Json.Serialization; using System.Xml.Serialization; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -27,7 +28,7 @@ public class Playlist [JsonIgnore] public User? Creator { get; set; } - public int Hearts(Database database) => database.HeartedPlaylists.Count(p => p.HeartedPlaylistId == this.PlaylistId); + public int Hearts(DatabaseContext database) => database.HeartedPlaylists.Count(p => p.HeartedPlaylistId == this.PlaylistId); public string SlotCollection { get; set; } = ""; @@ -45,7 +46,7 @@ public class Playlist public string Serialize() { - using Database database = new(); + using DatabaseContext database = new(); string playlist = LbpSerializer.StringElement("id", this.PlaylistId) + LbpSerializer.StringElement("author", LbpSerializer.StringElement("npHandle", this.Creator?.Username)) + @@ -59,7 +60,7 @@ public class Playlist return LbpSerializer.StringElement("playlist", playlist); } - private string SerializeIcons(Database database) + private string SerializeIcons(DatabaseContext database) { string iconList = this.SlotIds.Select(id => database.Slots.FirstOrDefault(s => s.SlotId == id)) .Where(slot => slot != null && slot.IconHash.Length > 0) diff --git a/ProjectLighthouse/Types/Entities/Level/Slot.cs b/ProjectLighthouse/Types/Entities/Level/Slot.cs index 8281d324..ad34e702 100644 --- a/ProjectLighthouse/Types/Entities/Level/Slot.cs +++ b/ProjectLighthouse/Types/Entities/Level/Slot.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text.Json.Serialization; using System.Xml.Serialization; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; @@ -28,16 +29,16 @@ public class Slot [NotMapped] [JsonIgnore] [XmlIgnore] - private Database? _database; + private DatabaseContext? _database; [NotMapped] [JsonIgnore] [XmlIgnore] - private Database database { + private DatabaseContext database { get { if (this._database != null) return this._database; - return this._database = new Database(); + return this._database = new DatabaseContext(); } set => this._database = value; } diff --git a/ProjectLighthouse/Types/Entities/Moderation/ModerationCase.cs b/ProjectLighthouse/Types/Entities/Moderation/ModerationCase.cs index d6700e83..c53128fc 100644 --- a/ProjectLighthouse/Types/Entities/Moderation/ModerationCase.cs +++ b/ProjectLighthouse/Types/Entities/Moderation/ModerationCase.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Moderation.Cases; @@ -47,13 +48,13 @@ public class ModerationCase public int AffectedId { get; set; } #region Get affected id result - public Task GetUserAsync(Database database) + public Task GetUserAsync(DatabaseContext database) { Debug.Assert(this.Type.AffectsUser()); return database.Users.FirstOrDefaultAsync(u => u.UserId == this.AffectedId); } - public Task GetSlotAsync(Database database) + public Task GetSlotAsync(DatabaseContext database) { Debug.Assert(this.Type.AffectsLevel()); return database.Slots.FirstOrDefaultAsync(u => u.SlotId == this.AffectedId); diff --git a/ProjectLighthouse/Types/Entities/Profile/Comment.cs b/ProjectLighthouse/Types/Entities/Profile/Comment.cs index 23d53d2c..ba311ff6 100644 --- a/ProjectLighthouse/Types/Entities/Profile/Comment.cs +++ b/ProjectLighthouse/Types/Entities/Profile/Comment.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Xml.Serialization; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Serialization; namespace LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -59,7 +60,7 @@ public class Comment return "This comment has been deleted by the author."; } - using Database database = new(); + using DatabaseContext database = new(); User deletedBy = database.Users.FirstOrDefault(u => u.Username == this.DeletedBy); if (deletedBy != null && deletedBy.UserId == this.TargetId) diff --git a/ProjectLighthouse/Types/Entities/Profile/Photo.cs b/ProjectLighthouse/Types/Entities/Profile/Photo.cs index 15619073..80e20170 100644 --- a/ProjectLighthouse/Types/Entities/Profile/Photo.cs +++ b/ProjectLighthouse/Types/Entities/Profile/Photo.cs @@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Xml.Serialization; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Levels; @@ -71,7 +72,7 @@ public class Photo if (this._subjects != null) return this._subjects; List response = new(); - using Database database = new(); + using DatabaseContext database = new(); foreach (string idStr in this.PhotoSubjectIds.Where(idStr => !string.IsNullOrEmpty(idStr))) { @@ -111,7 +112,7 @@ public class Photo public string Serialize() { - using Database database = new(); + using DatabaseContext database = new(); var partialSlot = database.Slots.Where(s => s.SlotId == this.SlotId.GetValueOrDefault()) .Select(s => new { diff --git a/ProjectLighthouse/Types/Entities/Profile/User.cs b/ProjectLighthouse/Types/Entities/Profile/User.cs index 710a98cb..078c75bc 100644 --- a/ProjectLighthouse/Types/Entities/Profile/User.cs +++ b/ProjectLighthouse/Types/Entities/Profile/User.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text.Json.Serialization; using System.Xml.Serialization; using LBPUnion.ProjectLighthouse.Configuration; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types.Misc; using LBPUnion.ProjectLighthouse.Types.Users; @@ -17,15 +18,15 @@ public class User #nullable enable [NotMapped] [JsonIgnore] - private Database? _database; + private DatabaseContext? _database; [NotMapped] [JsonIgnore] - private Database database { + private DatabaseContext database { get { if (this._database != null) return this._database; - return this._database = new Database(); + return this._database = new DatabaseContext(); } set => this._database = value; } diff --git a/ProjectLighthouse/Types/Levels/Category.cs b/ProjectLighthouse/Types/Levels/Category.cs index 0ae41e25..8749fdd9 100644 --- a/ProjectLighthouse/Types/Levels/Category.cs +++ b/ProjectLighthouse/Types/Levels/Category.cs @@ -1,6 +1,7 @@ #nullable enable using System.Collections.Generic; using System.Xml.Serialization; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types.Entities.Level; @@ -28,13 +29,13 @@ public abstract class Category set => this.Endpoint = value.Replace("/searches/", ""); } - public abstract Slot? GetPreviewSlot(Database database); + public abstract Slot? GetPreviewSlot(DatabaseContext database); - public abstract IEnumerable GetSlots(Database database, int pageStart, int pageSize); + public abstract IEnumerable GetSlots(DatabaseContext database, int pageStart, int pageSize); - public abstract int GetTotalSlots(Database database); + public abstract int GetTotalSlots(DatabaseContext database); - public string Serialize(Database database) + public string Serialize(DatabaseContext database) { Slot? previewSlot = this.GetPreviewSlot(database); diff --git a/ProjectLighthouse/Types/Maintenance/IMigrationTask.cs b/ProjectLighthouse/Types/Maintenance/IMigrationTask.cs index 3ad239ee..774a6cff 100644 --- a/ProjectLighthouse/Types/Maintenance/IMigrationTask.cs +++ b/ProjectLighthouse/Types/Maintenance/IMigrationTask.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using JetBrains.Annotations; +using LBPUnion.ProjectLighthouse.Database; namespace LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -16,5 +17,5 @@ public interface IMigrationTask /// /// The Lighthouse database. /// True if successful, false if not. - internal Task Run(Database database); + internal Task Run(DatabaseContext database); } \ No newline at end of file diff --git a/ProjectLighthouse/Types/Maintenance/IRepeatingTask.cs b/ProjectLighthouse/Types/Maintenance/IRepeatingTask.cs index a4b2ce45..af5e0ecf 100644 --- a/ProjectLighthouse/Types/Maintenance/IRepeatingTask.cs +++ b/ProjectLighthouse/Types/Maintenance/IRepeatingTask.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; namespace LBPUnion.ProjectLighthouse.Types.Maintenance; @@ -9,5 +10,5 @@ public interface IRepeatingTask public TimeSpan RepeatInterval { get; } public DateTime LastRan { get; set; } - public Task Run(Database database); + public Task Run(DatabaseContext database); } \ No newline at end of file diff --git a/ProjectLighthouse/Types/Moderation/Cases/CaseType.cs b/ProjectLighthouse/Types/Moderation/Cases/CaseType.cs index a1ea80e9..ceb16dbb 100644 --- a/ProjectLighthouse/Types/Moderation/Cases/CaseType.cs +++ b/ProjectLighthouse/Types/Moderation/Cases/CaseType.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Extensions; namespace LBPUnion.ProjectLighthouse.Types.Moderation.Cases; @@ -43,7 +44,7 @@ public static class CaseTypeExtensions }; } - public static async Task IsIdValid(this CaseType type, int affectedId, Database database) + public static async Task IsIdValid(this CaseType type, int affectedId, DatabaseContext database) { if (type.AffectsUser()) return await database.Users.Has(u => u.UserId == affectedId); if (type.AffectsLevel()) return await database.Slots.Has(u => u.SlotId == affectedId); diff --git a/ProjectLighthouse/Types/Users/UserStatus.cs b/ProjectLighthouse/Types/Users/UserStatus.cs index acdcda6c..57e8ebb7 100644 --- a/ProjectLighthouse/Types/Users/UserStatus.cs +++ b/ProjectLighthouse/Types/Users/UserStatus.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Linq; +using LBPUnion.ProjectLighthouse.Database; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; @@ -26,7 +27,7 @@ public class UserStatus public UserStatus() {} - public UserStatus(Database database, int userId) + public UserStatus(DatabaseContext database, int userId) { LastContact? lastContact = database.LastContacts.Where(l => l.UserId == userId).FirstOrDefault(l => TimeHelper.Timestamp - l.Timestamp < 300);