Skip to content
Merged
Show file tree
Hide file tree
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 @@ -47,7 +47,6 @@ public async Task SeedAsync(DataSeedContext context)

await SeedApplicationStatusAsync();
await SeedAiScoringPersonAsync(context.TenantId);
await SeedBackgroundJobUserAsync(context.TenantId);
}


Expand Down Expand Up @@ -119,43 +118,4 @@ await userRepository.InsertAsync(
}
}
}

private async Task SeedBackgroundJobUserAsync(System.Guid? tenantId)
{
// Ensure we're in the correct tenant context
using (currentTenant.Change(tenantId))
{
// 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,
tenantId)
{
Name = BackgroundJobConstants.BackgroundJobName
},
autoSave: true);
}

// Check if the Person record already exists
var existingPerson = await personRepository.FirstOrDefaultAsync(p => p.Id == BackgroundJobConstants.BackgroundJobPersonId);
if (existingPerson == null)
{
await personRepository.InsertAsync(new Person
{
Id = BackgroundJobConstants.BackgroundJobPersonId,
OidcSub = BackgroundJobConstants.BackgroundJobOidcSub,
OidcDisplayName = BackgroundJobConstants.BackgroundJobDisplayName,
FullName = BackgroundJobConstants.BackgroundJobDisplayName,
Badge = BackgroundJobConstants.BackgroundJobBadge,
TenantId = tenantId
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Threading;
using Volo.Abp.EntityFrameworkCore;
using System.Threading.Tasks;
using Unity.GrantManager.Applications;
using Unity.Modules.Shared.Constants;
using Volo.Abp.AuditLogging;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using Volo.Abp.Identity;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity;

namespace Unity.GrantManager.Repositories
{
Expand Down Expand Up @@ -53,7 +54,12 @@ public virtual async Task<List<EntityChangeWithUsername>> GetEntityChangeByTypeW

private async Task<string> ResolveUsername(Guid userId)
{
var user = await identityUserRepository.GetAsync(userId);
if(userId == BackgroundJobConstants.BackgroundJobPersonId)
{
return $"{BackgroundJobConstants.BackgroundJobName}";
}

var user = await identityUserRepository.GetAsync(userId);
return user != null ? $"{user.Name} {user.Surname}" : string.Empty;
}
}
Expand Down
Loading