diff --git a/applications/Unity.GrantManager/src/Unity.GrantManager.Domain/GrantManagerDataSeederContributor.cs b/applications/Unity.GrantManager/src/Unity.GrantManager.Domain/GrantManagerDataSeederContributor.cs index e4f4129abe..3958d29de3 100644 --- a/applications/Unity.GrantManager/src/Unity.GrantManager.Domain/GrantManagerDataSeederContributor.cs +++ b/applications/Unity.GrantManager/src/Unity.GrantManager.Domain/GrantManagerDataSeederContributor.cs @@ -47,7 +47,6 @@ public async Task SeedAsync(DataSeedContext context) await SeedApplicationStatusAsync(); await SeedAiScoringPersonAsync(context.TenantId); - await SeedBackgroundJobUserAsync(context.TenantId); } @@ -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 - }); - } - } - } } diff --git a/applications/Unity.GrantManager/src/Unity.GrantManager.EntityFrameworkCore/Repositories/EfCoreAuditLogRepository.cs b/applications/Unity.GrantManager/src/Unity.GrantManager.EntityFrameworkCore/Repositories/EfCoreAuditLogRepository.cs index a9d3225bce..2a95ae26c9 100644 --- a/applications/Unity.GrantManager/src/Unity.GrantManager.EntityFrameworkCore/Repositories/EfCoreAuditLogRepository.cs +++ b/applications/Unity.GrantManager/src/Unity.GrantManager.EntityFrameworkCore/Repositories/EfCoreAuditLogRepository.cs @@ -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 { @@ -53,7 +54,12 @@ public virtual async Task> GetEntityChangeByTypeW private async Task 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; } }