Skip to content
Merged

Dev #2147

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public async Task SeedAsync(DataSeedContext context)

if (context.TenantId == null) // only seed into a tenant database
{
await SeedMainBackgroundJobUserAsync(null);
return;
}

Expand Down Expand Up @@ -95,6 +96,30 @@ await personRepository.InsertAsync(new Person
}
}


private async Task SeedMainBackgroundJobUserAsync(System.Guid? tenantId)
{
using (currentTenant.Change(tenantId)) // Null For Main Unity Grant Manager Context
{
// Check if the IdentityUser already exists
var existingUser = await userRepository.FindAsync(BackgroundJobConstants.BackgroundJobPersonId);
if (existingUser == null)
{
// Create the IdentityUser in the tenant context
await userRepository.InsertAsync(
new IdentityUser(
BackgroundJobConstants.BackgroundJobPersonId,
BackgroundJobConstants.BackgroundJobUserName,
BackgroundJobConstants.BackgroundJobEmail,
null)
{
Name = BackgroundJobConstants.BackgroundJobName
},
autoSave: true);
}
}
}

private async Task SeedBackgroundJobUserAsync(System.Guid? tenantId)
{
// Ensure we're in the correct tenant context
Expand Down
Loading