2018-04-08 02:44:42 -04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using SharedLibraryCore.Database.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SharedLibraryCore.Database
|
|
|
|
|
{
|
|
|
|
|
public class ContextSeed
|
|
|
|
|
{
|
|
|
|
|
private DatabaseContext context;
|
|
|
|
|
|
|
|
|
|
public ContextSeed(DatabaseContext ctx)
|
|
|
|
|
{
|
|
|
|
|
context = ctx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task Seed()
|
|
|
|
|
{
|
2018-04-09 15:17:10 -04:00
|
|
|
|
// make sure database exists
|
|
|
|
|
//context.Database.EnsureCreated();
|
|
|
|
|
context.Database.Migrate();
|
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
if (context.AliasLinks.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
context.AliasLinks.Add(new EFAliasLink()
|
|
|
|
|
{
|
|
|
|
|
AliasLinkId = 1
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var currentAlias = new EFAlias()
|
|
|
|
|
{
|
|
|
|
|
AliasId = 1,
|
|
|
|
|
Active = true,
|
|
|
|
|
DateAdded = DateTime.UtcNow,
|
|
|
|
|
IPAddress = 0,
|
|
|
|
|
Name = "IW4MAdmin",
|
|
|
|
|
LinkId = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
context.Aliases.Add(currentAlias);
|
|
|
|
|
|
|
|
|
|
context.Clients.Add(new EFClient()
|
|
|
|
|
{
|
|
|
|
|
ClientId = 1,
|
|
|
|
|
Active = false,
|
|
|
|
|
Connections = 0,
|
|
|
|
|
FirstConnection = DateTime.UtcNow,
|
|
|
|
|
LastConnection = DateTime.UtcNow,
|
|
|
|
|
Level = Objects.Player.Permission.Console,
|
|
|
|
|
Masked = true,
|
|
|
|
|
NetworkId = 0,
|
|
|
|
|
AliasLinkId = 1,
|
|
|
|
|
CurrentAliasId = 1,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|