This commit is contained in:
@@ -345,13 +345,7 @@ namespace AyaNova.Api.Controllers
|
||||
else
|
||||
{
|
||||
|
||||
//save to get Id
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log now that we have the Id
|
||||
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.User, AyaEvent.Created), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
|
||||
//return success and link
|
||||
//NOTE: this is a USER object so we don't want to return some key fields for security reasons
|
||||
//which is why the object is "cleaned" before return
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace AyaNova.Models
|
||||
{
|
||||
public virtual DbSet<Event> Event { get; set; }
|
||||
public virtual DbSet<User> User { get; set; }
|
||||
public virtual DbSet<UserOptions> UserOptions { get; set; }
|
||||
public virtual DbSet<License> License { get; set; }
|
||||
public virtual DbSet<Widget> Widget { get; set; }
|
||||
public virtual DbSet<FileAttachment> FileAttachment { get; set; }
|
||||
@@ -30,6 +31,7 @@ namespace AyaNova.Models
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
//AUTOMATICALLY MATCH NAMES
|
||||
//https://andrewlock.net/customising-asp-net-core-identity-ef-core-naming-conventions-for-postgresql/
|
||||
foreach (var entity in modelBuilder.Model.GetEntityTypes())
|
||||
{
|
||||
|
||||
@@ -11,11 +11,23 @@ namespace AyaNova.Models
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
[Required]
|
||||
public long UserId { get; set; }
|
||||
//-------------
|
||||
public string EmailAddress { get; set; }
|
||||
public decimal? TimeZoneOffset { get; set; }
|
||||
public decimal TimeZoneOffset { get; set; }
|
||||
public int UiColor { get; set; }
|
||||
|
||||
public UserOptions(long userId, long ownerId)
|
||||
{
|
||||
UserId=userId;
|
||||
TimeZoneOffset=0;
|
||||
UiColor=0;
|
||||
OwnerId=ownerId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
v7 export record sample
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace AyaNova.Util
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
|
||||
private const int DESIRED_SCHEMA_LEVEL = 9;
|
||||
|
||||
internal const long EXPECTED_COLUMN_COUNT = 77;
|
||||
internal const long EXPECTED_INDEX_COUNT = 15;
|
||||
internal const long EXPECTED_COLUMN_COUNT = 83;
|
||||
internal const long EXPECTED_INDEX_COUNT = 16;
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -144,7 +144,8 @@ namespace AyaNova.Util
|
||||
"dlkey text, dlkeyexpire timestamp, usertype integer not null, employeenumber varchar(255), notes text, clientid bigint, headofficeid bigint, subvendorid bigint)");
|
||||
|
||||
//Add user options table
|
||||
exec("CREATE TABLE auseroptions (id BIGSERIAL PRIMARY KEY, ownerid bigint not null)");
|
||||
exec("CREATE TABLE auseroptions (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, "+
|
||||
"userid bigint not null, timezoneoffset decimal(19,5) not null default 0, emailaddress text, uicolor int not null default 0)");
|
||||
|
||||
|
||||
//Prime the db with the default MANAGER account
|
||||
@@ -176,7 +177,7 @@ namespace AyaNova.Util
|
||||
//Add widget table
|
||||
//id, text, longtext, boolean, currency,
|
||||
exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, " +
|
||||
"startdate timestamp, enddate timestamp, dollaramount money, active bool, roles int4)");
|
||||
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4)");
|
||||
|
||||
setSchemaLevel(++currentSchema);
|
||||
}
|
||||
|
||||
@@ -272,6 +272,8 @@ namespace AyaNova.Util
|
||||
foreach (long l in ItemsAdded)
|
||||
{
|
||||
EventLogProcessor.AddEntry(new Event(1, l, AyaType.User, AyaEvent.Created), ct);
|
||||
UserOptions UO=new UserOptions(l,1);
|
||||
ct.UserOptions.Add(UO);
|
||||
}
|
||||
|
||||
//Now save the Event Log entries
|
||||
|
||||
Reference in New Issue
Block a user