From 7d4d945f8a696ac4444adafc435f7da860c1b819 Mon Sep 17 00:00:00 2001 From: acn-sbuad Date: Tue, 4 Jun 2024 17:23:38 +0200 Subject: [PATCH] currently running ok. Add missing functionality for lookup --- .../LocalProfileClient.cs | 31 +++++++---------- .../LocalRegisterClient.cs | 34 +++++++++++++++++-- .../NotificationsServiceExtentions.cs | 9 ++++- 3 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/Notifications/LocalTestNotifications/LocalProfileClient.cs b/src/Notifications/LocalTestNotifications/LocalProfileClient.cs index cddf2b12..92ad9848 100644 --- a/src/Notifications/LocalTestNotifications/LocalProfileClient.cs +++ b/src/Notifications/LocalTestNotifications/LocalProfileClient.cs @@ -21,25 +21,20 @@ public async Task> GetUserContactPoints(List nat List contactPoints = new(); var data = await _testDataService.GetTestData(); - List users = new(); - - foreach (var item in data.Profile.User) - { - users.AddRange(data.Profile.User - .Where(u => nationalIdentityNumbers.Contains(u.Value.Party.SSN)) - .Select(u => u.Value) - .ToList()); - } - - foreach (UserProfile user in users) - { - contactPoints.Add(new UserContactPoints() + + contactPoints.AddRange(data.Profile.User + .Where(u => nationalIdentityNumbers.Contains(u.Value.Party.SSN)) + .Select(u => { - NationalIdentityNumber = user.Party.SSN, - Email = user.Email, - MobileNumber = user.PhoneNumber - }); - } + var user = u.Value; + return new UserContactPoints() + { + NationalIdentityNumber = user.Party.SSN, + Email = user.Email, + MobileNumber = user.PhoneNumber + }; + }) + .ToList()); return contactPoints; diff --git a/src/Notifications/LocalTestNotifications/LocalRegisterClient.cs b/src/Notifications/LocalTestNotifications/LocalRegisterClient.cs index d20d4bbf..f01b8cf3 100644 --- a/src/Notifications/LocalTestNotifications/LocalRegisterClient.cs +++ b/src/Notifications/LocalTestNotifications/LocalRegisterClient.cs @@ -1,13 +1,43 @@ using Altinn.Notifications.Core.Integrations; using Altinn.Notifications.Core.Models.ContactPoints; +using Altinn.Platform.Profile.Models; +using Altinn.Platform.Register.Models; + +using LocalTest.Services.TestData; namespace LocalTest.Notifications.LocalTestNotifications { public class LocalRegisterClient : IRegisterClient { - public Task> GetOrganizationContactPoints(List organizationNumbers) + private readonly TestDataService _testDataService; + + public LocalRegisterClient(TestDataService testDataService) + { + _testDataService = testDataService; + } + + public async Task> GetOrganizationContactPoints(List organizationNumbers) { - throw new NotImplementedException(); + var data = await _testDataService.GetTestData(); + + List orgContactPoints = new(); + + + orgContactPoints.AddRange(data.Register.Org + .Where(o => organizationNumbers.Contains(o.Value.OrgNumber)) + .Select(o => + { + var organization = o.Value; + return new OrganizationContactPoints() + { + OrganizationNumber = organization.OrgNumber, + EmailList = new List() { organization.EMailAddress }, + MobileNumberList = new List() { organization.MobileNumber } + }; + }) + .ToList()); + + return orgContactPoints; } } } diff --git a/src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs b/src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs index 02bda757..1f1e5f0d 100644 --- a/src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs +++ b/src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs @@ -1,12 +1,15 @@ using Altinn.Notifications.Core.Configuration; +using Altinn.Notifications.Core.Integrations; using Altinn.Notifications.Core.Persistence; using Altinn.Notifications.Core.Services; using Altinn.Notifications.Core.Services.Interfaces; using Altinn.Notifications.Extensions; using Altinn.Notifications.Models; using Altinn.Notifications.Validators; + using FluentValidation; using LocalTest.Notifications.Persistence.Repository; +using LocalTest.Services.TestData; namespace LocalTest.Notifications.LocalTestNotifications; @@ -26,6 +29,10 @@ public static void AddNotificationServices(this IServiceCollection services, str .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton(); + .AddSingleton() + .AddSingleton(); + + services.AddSingleton(); + services.AddSingleton(); } } \ No newline at end of file