2018-04-08 02:44:42 -04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using SharedLibraryCore.Database.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2018-11-05 22:01:29 -05:00
|
|
|
|
using static SharedLibraryCore.Database.Models.EFClient;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
context.Database.Migrate();
|
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
if (context.AliasLinks.Count() == 0)
|
|
|
|
|
{
|
2019-04-28 21:54:11 -04:00
|
|
|
|
var link = new EFAliasLink();
|
2018-04-08 02:44:42 -04:00
|
|
|
|
|
|
|
|
|
context.Clients.Add(new EFClient()
|
|
|
|
|
{
|
|
|
|
|
ClientId = 1,
|
|
|
|
|
Active = false,
|
|
|
|
|
Connections = 0,
|
|
|
|
|
FirstConnection = DateTime.UtcNow,
|
|
|
|
|
LastConnection = DateTime.UtcNow,
|
2018-11-05 22:01:29 -05:00
|
|
|
|
Level = Permission.Console,
|
2018-04-08 02:44:42 -04:00
|
|
|
|
Masked = true,
|
|
|
|
|
NetworkId = 0,
|
2019-04-28 21:54:11 -04:00
|
|
|
|
AliasLink = link,
|
|
|
|
|
CurrentAlias = new EFAlias()
|
|
|
|
|
{
|
|
|
|
|
Link = link,
|
|
|
|
|
Active = true,
|
|
|
|
|
DateAdded = DateTime.UtcNow,
|
|
|
|
|
Name = "IW4MAdmin",
|
|
|
|
|
},
|
2018-04-08 02:44:42 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|