From 0eef9a98a5e6512fd71e0e74a693c29bc8bfb854 Mon Sep 17 00:00:00 2001 From: adrianwium <82496337+adrianwium@users.noreply.github.com> Date: Tue, 10 Dec 2024 08:25:43 +0200 Subject: [PATCH] Testing and bug fixing --- src/api/Yoma.Core.sln | 1 + .../Yoma.Core.Domain/ActionLink/Services/LinkService.cs | 1 - .../domain/Yoma.Core.Domain/Entity/Services/UserService.cs | 2 -- .../MyOpportunity/Services/MyOpportunityService.cs | 5 +++-- src/api/src/other/MyOpportunityInfoCsvImport_Sample.csv | 6 ++++++ 5 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 src/api/src/other/MyOpportunityInfoCsvImport_Sample.csv diff --git a/src/api/Yoma.Core.sln b/src/api/Yoma.Core.sln index 9d56e8c14..003529d05 100644 --- a/src/api/Yoma.Core.sln +++ b/src/api/Yoma.Core.sln @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution src\scripts\index_fragmentation_postgre.sql = src\scripts\index_fragmentation_postgre.sql src\scripts\index_rebuild_reorganize_ms.sql = src\scripts\index_rebuild_reorganize_ms.sql src\scripts\index_rebuild_reorganize_postgre.sql = src\scripts\index_rebuild_reorganize_postgre.sql + src\other\MyOpportunityInfoCsvImport_Sample.csv = src\other\MyOpportunityInfoCsvImport_Sample.csv src\other\OpportunityInfoCsvImport_Sample.csv = src\other\OpportunityInfoCsvImport_Sample.csv EndProjectSection EndProject diff --git a/src/api/src/domain/Yoma.Core.Domain/ActionLink/Services/LinkService.cs b/src/api/src/domain/Yoma.Core.Domain/ActionLink/Services/LinkService.cs index 6f4769013..8772c746c 100644 --- a/src/api/src/domain/Yoma.Core.Domain/ActionLink/Services/LinkService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/ActionLink/Services/LinkService.cs @@ -24,7 +24,6 @@ using Yoma.Core.Domain.Entity.Models; using Yoma.Core.Domain.IdentityProvider.Extensions; using Yoma.Core.Domain.IdentityProvider.Interfaces; -using Yoma.Core.Domain.Opportunity; using Yoma.Core.Domain.Opportunity.Extensions; using Yoma.Core.Domain.Opportunity.Interfaces; using Yoma.Core.Domain.ShortLinkProvider.Interfaces; diff --git a/src/api/src/domain/Yoma.Core.Domain/Entity/Services/UserService.cs b/src/api/src/domain/Yoma.Core.Domain/Entity/Services/UserService.cs index b79a813cb..1db8d7425 100644 --- a/src/api/src/domain/Yoma.Core.Domain/Entity/Services/UserService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/Entity/Services/UserService.cs @@ -290,8 +290,6 @@ public async Task Upsert(UserRequest request) // profile fields updatable via UserProfileService.Update; identity provider is source of truth if (isNew) { - var kcUser = await _identityProviderClient.GetUserByUsername(request.Username) - ?? throw new InvalidOperationException($"{nameof(User)} with username '{request.Username}' does not exist"); result.FirstName = request.FirstName; result.Surname = request.Surname; result.DisplayName = request.DisplayName; diff --git a/src/api/src/domain/Yoma.Core.Domain/MyOpportunity/Services/MyOpportunityService.cs b/src/api/src/domain/Yoma.Core.Domain/MyOpportunity/Services/MyOpportunityService.cs index 4c2397b39..87c045443 100644 --- a/src/api/src/domain/Yoma.Core.Domain/MyOpportunity/Services/MyOpportunityService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/MyOpportunity/Services/MyOpportunityService.cs @@ -1051,7 +1051,7 @@ private async Task ProcessImportVerification(MyOpportunityRequestVerifyImportCsv throw new ValidationException("Opportunity external id required"); var opportunity = _opportunityService.GetByExternalId(requestImport.OrganizationId, item.OpporunityExternalId, true, true); - if(opportunity.VerificationMethod != VerificationMethod.Automatic) + if (opportunity.VerificationMethod != VerificationMethod.Automatic) throw new ValidationException($"Verification import not supported for opporunity '{opportunity.Title}'. The verification method must be set to 'Automatic'"); var user = _userService.GetByUsernameOrNull(username, false, false); @@ -1060,8 +1060,10 @@ private async Task ProcessImportVerification(MyOpportunityRequestVerifyImportCsv { var request = new UserRequest { + Id = user?.Id, Username = username, Email = item.Email, + PhoneNumber = item.PhoneNumber, FirstName = item.FirstName, Surname = item.Surname, EmailConfirmed = item.Email == null ? null : false, @@ -1084,7 +1086,6 @@ await _executionStrategyService.ExecuteInExecutionStrategyAsync(async () => scope.Complete(); }); - } private static List<(DateTime WeekEnding, int Count)> SummaryGroupByWeekItems(List items) diff --git a/src/api/src/other/MyOpportunityInfoCsvImport_Sample.csv b/src/api/src/other/MyOpportunityInfoCsvImport_Sample.csv new file mode 100644 index 000000000..ba19a01aa --- /dev/null +++ b/src/api/src/other/MyOpportunityInfoCsvImport_Sample.csv @@ -0,0 +1,6 @@ +Email,PhoneNumber,FirstName,Surname,Gender,Country,OpporunityExternalId +,1234567890,John,Doe,Male,US,External_ID1 +jane.smith@example.com,,Jane,Smith,Female,GB,External_ID2 +ali.khan@example.com,5512345678,,,Male,PK,External_ID3 +maria.garcia@example.com,34987654321,Maria,Garcia,,,External_ID4 +ali.khan@example.com,5512345678,Jim,Chen,Male,CN,External_ID5