This commit is contained in:
2018-08-29 15:07:17 +00:00
parent 3e1a48a6b7
commit 8c1d448ade

View File

@@ -60,10 +60,8 @@ namespace AyaNova.Util
//Erase all the data except for the license, schema and the manager user
DbUtil.PrepareDatabaseForSeeding(log);
var f = new Faker("en");
//Seed special test data for integration testing
SeedTestData();
SeedKnownUsers();
switch (slevel)
@@ -192,7 +190,7 @@ namespace AyaNova.Util
//////////////////////////////////////////////////////
//Seed test data for integration tests
//
public static void SeedTestData()
public static void SeedKnownUsers()
{
//TEST USERS
@@ -251,6 +249,25 @@ namespace AyaNova.Util
u.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
ct.User.Add(u);
}
//save to get id values
ct.SaveChanges();
//Now that we have the ID values bulk add the event log entries
//To save a db call iterate the local collection in the context, but...
//can't modify the context in the foreach, even if it's another collection entirely, so need to save the id's in a temporary list
List<long> ItemsAdded = new List<long>();
foreach (User o in ct.User.Local)
{
ItemsAdded.Add(o.Id);
}
//Now we have all the id's can actually add them to the context
foreach (long l in ItemsAdded)
{
EventLogProcessor.AddEntry(new Event(1, l, AyaType.User, AyaEvent.Created), ct);
}
//Now save the Event Log entries
ct.SaveChanges();
}