This commit is contained in:
2018-09-05 22:02:23 +00:00
parent e0e5dd1942
commit cd52c3e83f
7 changed files with 46 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ using AyaNova.Models;
namespace AyaNova.Biz
{
//Prime the database with initial, minimum required data to boot and do things (manager account, locales)
public static class PrimeData
{
// private readonly AyContext ct;
@@ -21,7 +22,7 @@ namespace AyaNova.Biz
// }
/// <summary>
/// Prime the database
/// Prime the database with manager account
/// </summary>
public static void PrimeManagerAccount(AyContext ct)
{
@@ -39,6 +40,9 @@ namespace AyaNova.Biz
u.UserType=UserType.Administrator;
ct.User.Add(u);
ct.SaveChanges();
UserOptions UO=new UserOptions(1,1);
ct.UserOptions.Add(UO);
ct.SaveChanges();
}

View File

@@ -48,11 +48,24 @@ namespace AyaNova.Biz
//do stuff with User
User outObj = inObj;
outObj.OwnerId = userId;
await ct.User.AddAsync(outObj);
//save to get Id
await ct.SaveChangesAsync();
//Handle child and associated items
//SearchHelper(break down text fields, save to db)
//TagHelper(collection of tags??)
await ct.User.AddAsync(outObj);
//Log event
EventLogProcessor.AddEntry(new Event(userId, outObj.Id, AyaType.User, AyaEvent.Created), ct);
UserOptions options = new UserOptions(outObj.Id, userId);
ct.UserOptions.Add(options);
//Save the final changes
await ct.SaveChangesAsync();
return outObj;
}
@@ -235,6 +248,9 @@ namespace AyaNova.Biz
{
//TAGS
TagMapBiz.DeleteAllForObject(new AyaTypeId(AyaType.User, dbObj.Id), ct);
//USEROPTIONS
ct.Database.ExecuteSqlCommand($"delete from auseroptions where userid={dbObj.Id}");
}
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -664,6 +680,7 @@ namespace AyaNova.Biz
var mapItem = new ImportAyaNova7MapItem(V7Id, AyaType.User, o.Id);
importMap.Add(mapItem);
}
#endregion
}