mirror of
https://github.com/CyberL1/MyMcRealms.git
synced 2025-06-28 17:39:42 -04:00
Import from Github
This commit is contained in:
52
Minecraft-Realms-Emulator/Helpers/Database.cs
Normal file
52
Minecraft-Realms-Emulator/Helpers/Database.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Minecraft_Realms_Emulator.Data;
|
||||
using Minecraft_Realms_Emulator.Entities;
|
||||
|
||||
namespace Minecraft_Realms_Emulator.Helpers
|
||||
{
|
||||
public class Database
|
||||
{
|
||||
public static void Initialize(WebApplication app)
|
||||
{
|
||||
var scope = app.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<DataContext>();
|
||||
|
||||
db.Database.Migrate();
|
||||
|
||||
if (db.Configuration.FirstOrDefault(s => s.Key == "newsLink") == null)
|
||||
{
|
||||
var newsLink = new Configuration
|
||||
{
|
||||
Key = "newsLink",
|
||||
Value = "\"https://github.com/CyberL1/Minecraft-Realms-Emulator\""
|
||||
};
|
||||
|
||||
db.Configuration.Add(newsLink);
|
||||
}
|
||||
|
||||
if (db.Configuration.FirstOrDefault(s => s.Key == "defaultServerAddress") == null)
|
||||
{
|
||||
var defaultServerAddress = new Configuration
|
||||
{
|
||||
Key = "defaultServerAddress",
|
||||
Value = "\"127.0.0.1\""
|
||||
};
|
||||
|
||||
db.Configuration.Add(defaultServerAddress);
|
||||
}
|
||||
|
||||
if (db.Configuration.FirstOrDefault(x => x.Key == "trialMode") == null)
|
||||
{
|
||||
var trialMode = new Configuration
|
||||
{
|
||||
Key = "trialMode",
|
||||
Value = true
|
||||
};
|
||||
|
||||
db.Configuration.Add(trialMode);
|
||||
}
|
||||
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user