This commit is contained in:
@@ -38,11 +38,10 @@ namespace AyaNova.Biz
|
|||||||
u.OwnerId = 1;
|
u.OwnerId = 1;
|
||||||
u.LocaleId=ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;//Ensure primeLocales is called first
|
u.LocaleId=ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;//Ensure primeLocales is called first
|
||||||
u.UserType=UserType.Administrator;
|
u.UserType=UserType.Administrator;
|
||||||
|
u.UserOptions=new UserOptions(1);
|
||||||
ct.User.Add(u);
|
ct.User.Add(u);
|
||||||
ct.SaveChanges();
|
ct.SaveChanges();
|
||||||
UserOptions UO=new UserOptions(1,1);
|
|
||||||
ct.UserOptions.Add(UO);
|
|
||||||
ct.SaveChanges();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ namespace AyaNova.Biz
|
|||||||
//do stuff with User
|
//do stuff with User
|
||||||
User outObj = inObj;
|
User outObj = inObj;
|
||||||
outObj.OwnerId = userId;
|
outObj.OwnerId = userId;
|
||||||
|
outObj.UserOptions = new UserOptions(userId);
|
||||||
|
|
||||||
await ct.User.AddAsync(outObj);
|
await ct.User.AddAsync(outObj);
|
||||||
//save to get Id
|
//save to get Id
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
@@ -60,8 +62,8 @@ namespace AyaNova.Biz
|
|||||||
//Log event
|
//Log event
|
||||||
EventLogProcessor.AddEntry(new Event(userId, outObj.Id, AyaType.User, AyaEvent.Created), ct);
|
EventLogProcessor.AddEntry(new Event(userId, outObj.Id, AyaType.User, AyaEvent.Created), ct);
|
||||||
|
|
||||||
UserOptions options = new UserOptions(outObj.Id, userId);
|
// UserOptions options = new UserOptions(outObj.Id, userId);
|
||||||
ct.UserOptions.Add(options);
|
// ct.UserOptions.Add(options);
|
||||||
|
|
||||||
//Save the final changes
|
//Save the final changes
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ namespace AyaNova.Models
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
property.Relational().ColumnName = property.Name.ToLowerInvariant();
|
property.Relational().ColumnName = property.Name.ToLowerInvariant();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var key in entity.GetKeys())
|
foreach (var key in entity.GetKeys())
|
||||||
@@ -69,21 +68,21 @@ namespace AyaNova.Models
|
|||||||
{
|
{
|
||||||
index.Relational().Name = index.Relational().Name.ToLowerInvariant();
|
index.Relational().Name = index.Relational().Name.ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Indexes must be specified through fluent api unfortunately
|
//Indexes must be specified through fluent api unfortunately
|
||||||
modelBuilder.Entity<FileAttachment>().HasIndex(p => p.StoredFileName);
|
modelBuilder.Entity<FileAttachment>().HasIndex(p => p.StoredFileName);
|
||||||
|
|
||||||
|
|
||||||
//Relationships
|
//Relationships
|
||||||
modelBuilder.Entity<Locale>()
|
modelBuilder.Entity<Locale>()
|
||||||
.HasMany(c => c.LocaleItems)
|
.HasMany(c => c.LocaleItems)
|
||||||
.WithOne(e => e.Locale)
|
.WithOne(e => e.Locale)
|
||||||
.IsRequired();//default delete behaviour is cascade when set to isrequired
|
.IsRequired();//default delete behaviour is cascade when set to isrequired
|
||||||
|
|
||||||
|
modelBuilder.Entity<User>()
|
||||||
|
.HasOne(p => p.UserOptions)
|
||||||
|
.WithOne(i => i.User)
|
||||||
|
.HasForeignKey<UserOptions>(b => b.UserId);
|
||||||
|
|
||||||
|
|
||||||
//-----------
|
//-----------
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ namespace AyaNova.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string Login { get; set; }
|
public string Login { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string Salt { get; set; }
|
public string Salt { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public AuthorizationRoles Roles { get; set; }
|
public AuthorizationRoles Roles { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public long LocaleId { get; set; }
|
public long LocaleId { get; set; }
|
||||||
public string DlKey { get; set; }
|
public string DlKey { get; set; }
|
||||||
@@ -31,11 +31,16 @@ namespace AyaNova.Models
|
|||||||
public UserType UserType { get; set; }
|
public UserType UserType { get; set; }
|
||||||
[MaxLength(255)]
|
[MaxLength(255)]
|
||||||
public string EmployeeNumber { get; set; }
|
public string EmployeeNumber { get; set; }
|
||||||
public string Notes { get; set; }
|
public string Notes { get; set; }
|
||||||
public long? ClientId { get; set; }
|
public long? ClientId { get; set; }
|
||||||
public long? HeadOfficeId { get; set; }
|
public long? HeadOfficeId { get; set; }
|
||||||
public long? SubVendorId { get; set; }
|
public long? SubVendorId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
//relations
|
||||||
|
//https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns
|
||||||
|
public UserOptions UserOptions { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -11,19 +11,25 @@ namespace AyaNova.Models
|
|||||||
public uint ConcurrencyToken { get; set; }
|
public uint ConcurrencyToken { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public long OwnerId { get; set; }
|
public long OwnerId { get; set; }
|
||||||
[Required]
|
|
||||||
public long UserId { get; set; }
|
|
||||||
//-------------
|
//-------------
|
||||||
public string EmailAddress { get; set; }
|
public string EmailAddress { get; set; }
|
||||||
public decimal TimeZoneOffset { get; set; }
|
public decimal TimeZoneOffset { get; set; }
|
||||||
public int UiColor { get; set; }
|
public int UiColor { get; set; }
|
||||||
|
|
||||||
public UserOptions(long userId, long ownerId)
|
//relations
|
||||||
|
//https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns
|
||||||
|
public User User { get; set; }
|
||||||
|
[Required]
|
||||||
|
public long UserId { get; set; }//will be auto-set by EF due to relationship defined
|
||||||
|
|
||||||
|
|
||||||
|
public UserOptions(long ownerId)
|
||||||
{
|
{
|
||||||
UserId=userId;
|
|
||||||
TimeZoneOffset=0;
|
TimeZoneOffset = 0;
|
||||||
UiColor=0;
|
UiColor = 0;
|
||||||
OwnerId=ownerId;
|
OwnerId = ownerId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ namespace AyaNova.Util
|
|||||||
//PRIVACY TEST USER - this is used for a test to see if user info leaks into the logs
|
//PRIVACY TEST USER - this is used for a test to see if user info leaks into the logs
|
||||||
GenSeedUser(1, AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, "TEST_PRIVACY_USER_ACCOUNT", "TEST_PRIVACY_USER_ACCOUNT");
|
GenSeedUser(1, AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, "TEST_PRIVACY_USER_ACCOUNT", "TEST_PRIVACY_USER_ACCOUNT");
|
||||||
|
|
||||||
//TEST NOT ACTIVE - this is used for a test to see if inactive user can login
|
//TEST NOT ACTIVE - this is used for a test to see if inactive user can login
|
||||||
GenSeedUser(1, AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, false, "TEST_INACTIVE", "TEST_INACTIVE");
|
GenSeedUser(1, AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, false, "TEST_INACTIVE", "TEST_INACTIVE");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -254,6 +254,10 @@ namespace AyaNova.Util
|
|||||||
u.UserType = userType;
|
u.UserType = userType;
|
||||||
//TODO: After have USER and HEADOFFICE and VENDOR, if usertype is subcontractor or client or headoffice it needs to set a corresponding user's parent org record id to go with it
|
//TODO: After have USER and HEADOFFICE and VENDOR, if usertype is subcontractor or client or headoffice it needs to set a corresponding user's parent org record id to go with it
|
||||||
|
|
||||||
|
//Children and relations
|
||||||
|
u.UserOptions = new UserOptions(1);
|
||||||
|
u.UserOptions.EmailAddress = p.Email.Replace("gmail.com","helloayanova.com").Replace("hotmail.com","helloayanova.com").Replace("yahoo.com","helloayanova.com");
|
||||||
|
|
||||||
ct.User.Add(u);
|
ct.User.Add(u);
|
||||||
}
|
}
|
||||||
//save to get id values
|
//save to get id values
|
||||||
@@ -271,9 +275,7 @@ namespace AyaNova.Util
|
|||||||
//Now we have all the id's can actually add them to the context
|
//Now we have all the id's can actually add them to the context
|
||||||
foreach (long l in ItemsAdded)
|
foreach (long l in ItemsAdded)
|
||||||
{
|
{
|
||||||
EventLogProcessor.AddEntry(new Event(1, l, AyaType.User, AyaEvent.Created), ct);
|
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
|
//Now save the Event Log entries
|
||||||
|
|||||||
Reference in New Issue
Block a user