- Profile
+ Profile
@@ -56,7 +67,6 @@
routerLinkActive="main-menu-item-active"
[routerLink]="getRouterLink(menuItem)"
[routerLinkActiveOptions]="getRouterLinkActiveOptions(menuItem)"
- [fragment]="getRouterLinkFragment(menuItem)"
(click)="onMenuItemClicked()"
>{{ menuItem.label }}
@@ -94,7 +104,7 @@
Personal Information
College License
+
User Access Agreement
-
+
diff --git a/workspace/apps/pidp/src/app/features/shell/components/portal-dashboard/portal-dashboard.component.ts b/workspace/apps/pidp/src/app/features/shell/components/portal-dashboard/portal-dashboard.component.ts
index 15ff36387..d366350a6 100644
--- a/workspace/apps/pidp/src/app/features/shell/components/portal-dashboard/portal-dashboard.component.ts
+++ b/workspace/apps/pidp/src/app/features/shell/components/portal-dashboard/portal-dashboard.component.ts
@@ -4,24 +4,25 @@ import { IsActiveMatchOptions } from '@angular/router';
import { Observable, map } from 'rxjs';
-import { DashboardStateModel, PidpStateName } from '@pidp/data-model';
-import { AppStateService } from '@pidp/presentation';
-
import {
DashboardHeaderConfig,
DashboardMenuItem,
DashboardRouteMenuItem,
IDashboard,
- NavMenuComponent,
} from '@bcgov/shared/ui';
import { APP_CONFIG, AppConfig } from '@app/app.config';
+import { AccessRoutes } from '@app/features/access/access.routes';
import { AccessTokenService } from '@app/features/auth/services/access-token.service';
import { AuthService } from '@app/features/auth/services/auth.service';
-import { PermissionsService } from '@app/modules/permissions/permissions.service';
+import {
+ DashboardStateModel,
+ PidpStateName,
+} from '@app/features/portal/models/state.model';
+import { AppStateService } from '../../services/app-state.service';
import { DashboardStateService } from '../../services/dashboard-state-service.service';
-import { AccessRoutes } from '@app/features/access/access.routes';
+import { NavMenuComponent } from '../navbar-menu/nav-menu';
@Component({
selector: 'app-portal-dashboard',
@@ -45,7 +46,6 @@ export class PortalDashboardComponent implements IDashboard, OnInit {
public constructor(
@Inject(APP_CONFIG) private config: AppConfig,
private authService: AuthService,
- private permissionsService: PermissionsService,
accessTokenService: AccessTokenService,
private dashboardStateService: DashboardStateService,
private stateService: AppStateService,
@@ -98,7 +98,7 @@ export class PortalDashboardComponent implements IDashboard, OnInit {
new DashboardRouteMenuItem(
'Access',
{
- commands:[AccessRoutes.BASE_PATH,AccessRoutes.ACCESS_REQUESTS],
+ commands: [AccessRoutes.BASE_PATH, AccessRoutes.ACCESS_REQUESTS],
linkActiveOptions,
},
'assignment',
diff --git a/workspace/libs/pidp/presentation/src/lib/services/app-state.service.ts b/workspace/apps/pidp/src/app/features/shell/services/app-state.service.ts
similarity index 97%
rename from workspace/libs/pidp/presentation/src/lib/services/app-state.service.ts
rename to workspace/apps/pidp/src/app/features/shell/services/app-state.service.ts
index 6570a6c2c..e481f39da 100644
--- a/workspace/libs/pidp/presentation/src/lib/services/app-state.service.ts
+++ b/workspace/apps/pidp/src/app/features/shell/services/app-state.service.ts
@@ -6,7 +6,7 @@ import {
ApplicationStateModel,
NamedState,
defaultApplicationState,
-} from '@pidp/data-model';
+} from '@app/features/portal/models/state.model';
@Injectable({
providedIn: 'root',
diff --git a/workspace/libs/pidp/presentation/src/lib/services/application.service.ts b/workspace/apps/pidp/src/app/features/shell/services/application.service.ts
similarity index 86%
rename from workspace/libs/pidp/presentation/src/lib/services/application.service.ts
rename to workspace/apps/pidp/src/app/features/shell/services/application.service.ts
index 955871020..3dba8a3ac 100644
--- a/workspace/libs/pidp/presentation/src/lib/services/application.service.ts
+++ b/workspace/apps/pidp/src/app/features/shell/services/application.service.ts
@@ -1,6 +1,9 @@
import { Injectable } from '@angular/core';
-import { DashboardStateModel, PidpStateName } from '@pidp/data-model';
+import {
+ DashboardStateModel,
+ PidpStateName,
+} from '@app/features/portal/models/state.model';
import { AppStateService } from './app-state.service';
diff --git a/workspace/apps/pidp/src/app/features/shell/services/dashboard-state-service.service.spec.ts b/workspace/apps/pidp/src/app/features/shell/services/dashboard-state-service.service.spec.ts
index b5bb7aa7e..3b3de851d 100644
--- a/workspace/apps/pidp/src/app/features/shell/services/dashboard-state-service.service.spec.ts
+++ b/workspace/apps/pidp/src/app/features/shell/services/dashboard-state-service.service.spec.ts
@@ -1,16 +1,19 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { TestBed } from '@angular/core/testing';
-import { DashboardStateModel, PidpStateName } from '@pidp/data-model';
-import { AppStateService } from '@pidp/presentation';
import { MockProfileStatus } from '@test/mock-profile-status';
import { Spy, createSpyFromClass, provideAutoSpy } from 'jest-auto-spies';
import { PartyService } from '@app/core/party/party.service';
import { ProfileStatus } from '@app/features/portal/models/profile-status.model';
+import {
+ DashboardStateModel,
+ PidpStateName,
+} from '@app/features/portal/models/state.model';
import { PortalResource } from '@app/features/portal/portal-resource.service';
import { LookupService } from '@app/modules/lookup/lookup.service';
+import { AppStateService } from './app-state.service';
import { DashboardStateService } from './dashboard-state-service.service';
describe('DashboardStateService', () => {
diff --git a/workspace/apps/pidp/src/app/features/shell/services/dashboard-state-service.service.ts b/workspace/apps/pidp/src/app/features/shell/services/dashboard-state-service.service.ts
index 23fe3d74a..3c67132ec 100644
--- a/workspace/apps/pidp/src/app/features/shell/services/dashboard-state-service.service.ts
+++ b/workspace/apps/pidp/src/app/features/shell/services/dashboard-state-service.service.ts
@@ -1,14 +1,17 @@
import { Injectable } from '@angular/core';
-import { DashboardStateModel, PidpStateName } from '@pidp/data-model';
-import { AppStateService } from '@pidp/presentation';
-
import { PartyService } from '@app/core/party/party.service';
import { ProfileStatus } from '@app/features/portal/models/profile-status.model';
+import {
+ DashboardStateModel,
+ PidpStateName,
+} from '@app/features/portal/models/state.model';
import { PortalResource } from '@app/features/portal/portal-resource.service';
import { ProfileRoutes } from '@app/features/profile/profile.routes';
import { LookupService } from '@app/modules/lookup/lookup.service';
+import { AppStateService } from './app-state.service';
+
@Injectable({
providedIn: 'root',
})
@@ -31,6 +34,7 @@ export class DashboardStateService {
const displayFullName = this.getUserDisplayFullName(profileStatus);
const collegeName = this.getCollegeName(profileStatus);
const collegeRoute = this.getCollegeRoute(profileStatus);
+ const alerts = profileStatus?.alerts ?? [];
// Set the user name and college on the dashboard.
const oldState = this.stateService.getNamedState(
@@ -41,6 +45,7 @@ export class DashboardStateService {
userProfileFullNameText: displayFullName,
userProfileCollegeNameText: collegeName,
collegeRoute,
+ alerts,
};
this.stateService.setNamedState(PidpStateName.dashboard, newState);
});
diff --git a/workspace/apps/pidp/src/app/features/training/pages/compliance-training/compliance-training-routing.routes.ts b/workspace/apps/pidp/src/app/features/training/pages/compliance-training/compliance-training-routing.routes.ts
index 1f16456df..bbbb2e0b5 100644
--- a/workspace/apps/pidp/src/app/features/training/pages/compliance-training/compliance-training-routing.routes.ts
+++ b/workspace/apps/pidp/src/app/features/training/pages/compliance-training/compliance-training-routing.routes.ts
@@ -11,11 +11,6 @@ export const routes: Routes = [
routes: {
root: '../../',
},
- setDashboardTitleGuard: {
- titleText: 'Welcome to OneHealthID Service',
- titleDescriptionText:
- 'Complete your profile to gain access to the systems you are eligible for',
- },
},
},
];
diff --git a/workspace/libs/pidp/data-model/src/index.ts b/workspace/libs/pidp/data-model/src/index.ts
index 819839ea4..bb73439d5 100644
--- a/workspace/libs/pidp/data-model/src/index.ts
+++ b/workspace/libs/pidp/data-model/src/index.ts
@@ -1,2 +1 @@
export * from './lib/models/registered-college.model';
-export * from './lib/models/state.model';
diff --git a/workspace/libs/pidp/data-model/tsconfig.lib.json b/workspace/libs/pidp/data-model/tsconfig.lib.json
index 9778b31d2..d8420b24c 100644
--- a/workspace/libs/pidp/data-model/tsconfig.lib.json
+++ b/workspace/libs/pidp/data-model/tsconfig.lib.json
@@ -13,5 +13,8 @@
"**/*.test.ts",
"jest.config.ts"
],
- "include": ["**/*.ts"]
+ "include": [
+ "**/*.ts",
+ "../../../apps/pidp/src/app/features/portal/models/state.model.ts"
+ ]
}
diff --git a/workspace/libs/pidp/presentation/src/index.ts b/workspace/libs/pidp/presentation/src/index.ts
index a718c0e5a..46bc697d7 100644
--- a/workspace/libs/pidp/presentation/src/index.ts
+++ b/workspace/libs/pidp/presentation/src/index.ts
@@ -1,5 +1,2 @@
-export * from './lib/guards/set-dashboard-title.guard';
-export * from './lib/services/app-state.service';
-export * from './lib/services/application.service';
export * from './lib/services/loading-overlay.service';
export * from './lib/services/navigation.service';
diff --git a/workspace/libs/pidp/presentation/src/lib/guards/set-dashboard-title.guard.spec.ts b/workspace/libs/pidp/presentation/src/lib/guards/set-dashboard-title.guard.spec.ts
deleted file mode 100644
index c1d2d64a5..000000000
--- a/workspace/libs/pidp/presentation/src/lib/guards/set-dashboard-title.guard.spec.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-import { CanActivateFn } from '@angular/router';
-
-import { setDashboardTitleGuard } from './set-dashboard-title.guard';
-
-describe('setDashboardTitleGuard', () => {
- const executeGuard: CanActivateFn = (...guardParameters) =>
- TestBed.runInInjectionContext(() =>
- setDashboardTitleGuard(...guardParameters),
- );
-
- beforeEach(() => {
- TestBed.configureTestingModule({});
- });
-
- it('should be created', () => {
- expect(executeGuard).toBeTruthy();
- });
-});
diff --git a/workspace/libs/pidp/presentation/src/lib/guards/set-dashboard-title.guard.ts b/workspace/libs/pidp/presentation/src/lib/guards/set-dashboard-title.guard.ts
deleted file mode 100644
index db4fe5079..000000000
--- a/workspace/libs/pidp/presentation/src/lib/guards/set-dashboard-title.guard.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { inject } from '@angular/core';
-import { ActivatedRouteSnapshot, CanActivateFn } from '@angular/router';
-
-import { ApplicationService } from '../services/application.service';
-
-export interface SetDashboardTitleGuardRouteData {
- titleText: string;
- titleDescriptionText: string;
-}
-
-/**
- * Use this to set the dashboard title and title description to static text
- * upon activation of any route.
- * Pass in route data named setDashboardTitleGuard that matches the
- * interface SetDashboardTitleGuardRouteData.
- */
-export const setDashboardTitleGuard: CanActivateFn = (
- route: ActivatedRouteSnapshot,
-) => {
- const applicationService = inject(ApplicationService);
-
- const data = route.data
- .setDashboardTitleGuard as SetDashboardTitleGuardRouteData;
- if (!data) {
- throw 'setDashboardTitleGuard requires a route data item named "setDashboardTitleGuard"';
- }
-
- applicationService.setDashboardTitleText(
- data.titleText,
- data.titleDescriptionText,
- );
-
- return true;
-};
diff --git a/workspace/libs/shared/ui/src/lib/modules/dashboard/components/index.ts b/workspace/libs/shared/ui/src/lib/modules/dashboard/components/index.ts
index f1d9d264d..ba8ba8196 100644
--- a/workspace/libs/shared/ui/src/lib/modules/dashboard/components/index.ts
+++ b/workspace/libs/shared/ui/src/lib/modules/dashboard/components/index.ts
@@ -2,4 +2,3 @@ export * from './dashboard/dashboard.component';
export * from './dashboard-route-menu-item/dashboard-route-menu-item.component';
export * from './dashboard-header/dashboard-header.component';
export * from './dashboard-image/dashboard-image.component';
-export * from './navbar-menu/nav-menu';
From 43f7f174df5a7853d183fd4fe6ed2c88021318cf Mon Sep 17 00:00:00 2001
From: James Hollinger <39168456+james-hollinger@users.noreply.github.com>
Date: Mon, 8 Jul 2024 13:49:39 -0700
Subject: [PATCH 07/16] PIDP-970 - Update DMFT EndorsementData API (#559)
---
.../ThirdPartyIntegrations/EndorsementData.cs | 152 ++++++++----------
.../ThirdPartyIntegrations/EndorsementData.cs | 58 ++++---
2 files changed, 94 insertions(+), 116 deletions(-)
diff --git a/backend/webapi.tests/Features/ThirdPartyIntegrations/EndorsementData.cs b/backend/webapi.tests/Features/ThirdPartyIntegrations/EndorsementData.cs
index b8b5858fe..b08ec8822 100644
--- a/backend/webapi.tests/Features/ThirdPartyIntegrations/EndorsementData.cs
+++ b/backend/webapi.tests/Features/ThirdPartyIntegrations/EndorsementData.cs
@@ -17,9 +17,9 @@ public class EndorsementDataTests : InMemoryDbTest
&& record.StatusReasonCode == result.StatusReasonCode;
[Fact]
- public async void GetEndorsementData_NoParty_404()
+ public async Task GetEndorsementData_NoParty_404()
{
- this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid"));
+ this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid@bcsc"));
var query = new EndorsementData.Query { Hpdid = "NoMatch" };
var handler = this.MockDependenciesFor();
@@ -29,33 +29,24 @@ public async void GetEndorsementData_NoParty_404()
}
[Fact]
- public async void GetEndorsementData_NoEndorsements_Empty()
+ public async Task GetEndorsementData_NoEndorsements_Empty()
{
- this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid"));
+ this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid@bcsc"));
var query = new EndorsementData.Query { Hpdid = "hpdid" };
var handler = this.MockDependenciesFor();
var result = await handler.HandleAsync(query);
Assert.True(result.IsSuccess);
- Assert.Equal(new List(), result.Value);
+ Assert.Equal([], result.Value);
}
[Fact]
- public async void GetEndorsementData_OneEndorsementNotActive_Empty()
+ public async Task GetEndorsementData_OneEndorsementNotActive_Empty()
{
- var expectedHpdid = "expected";
- this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid"));
- this.TestDb.Has(APartyWith(id: 2, hpdid: expectedHpdid));
- this.TestDb.Has(new Endorsement
- {
- Active = false,
- EndorsementRelationships = new[]
- {
- new EndorsementRelationship { PartyId = 1 },
- new EndorsementRelationship { PartyId = 2 }
- }
- });
+ this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid@bcsc"));
+ this.TestDb.Has(APartyWith(id: 2, hpdid: "anotherHpdid@bcsc"));
+ this.TestDb.Has(AnEndorsementBetween(1, 2, isActive: false));
var query = new EndorsementData.Query { Hpdid = "hpdid" };
var handler = this.MockDependenciesFor();
@@ -68,21 +59,12 @@ public async void GetEndorsementData_OneEndorsementNotActive_Empty()
[Theory]
[InlineData("hpdid")]
[InlineData("hpdid@bcsc")]
- public async void GetEndorsementData_OneEndorsementNoCpn_MatchingHpdidEmptyLicences(string partyHpdid)
+ public async Task GetEndorsementData_OneEndorsementNoCpn_MatchingHpdidEmptyLicences(string hpdidQuery)
{
- var expectedHpdid = "expected";
- this.TestDb.Has(APartyWith(id: 1, hpdid: partyHpdid));
- this.TestDb.Has(APartyWith(id: 2, hpdid: expectedHpdid));
- this.TestDb.Has(new Endorsement
- {
- Active = true,
- EndorsementRelationships = new[]
- {
- new EndorsementRelationship { PartyId = 1 },
- new EndorsementRelationship { PartyId = 2 }
- }
- });
- var query = new EndorsementData.Query { Hpdid = "hpdid" }; // Should match either "hpdid" or "hpdid@bcsc" (the actual form for HPDID we get from Keycloak)
+ this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid@bcsc"));
+ var otherParty = this.TestDb.Has(APartyWith(id: 2, hpdid: "anotherHpdid@bcsc"));
+ this.TestDb.Has(AnEndorsementBetween(1, 2));
+ var query = new EndorsementData.Query { Hpdid = hpdidQuery }; // Should match either "hpdid" or "hpdid@bcsc" (the actual form for HPDID we get from Keycloak and save in our database)
var handler = this.MockDependenciesFor();
var result = await handler.HandleAsync(query);
@@ -91,15 +73,14 @@ public async void GetEndorsementData_OneEndorsementNoCpn_MatchingHpdidEmptyLicen
Assert.Single(result.Value);
var model = result.Value.Single();
- Assert.Equal(expectedHpdid, model.Hpdid);
+ AssertBasicInfoMatches(otherParty, model);
Assert.NotNull(model.Licences);
Assert.Empty(model.Licences);
}
[Fact]
- public async void GetEndorsementData_OneEndorsementWithCpn_MatchingHpdidWithLicences()
+ public async Task GetEndorsementData_OneEndorsementWithCpn_MatchingHpdidWithLicences()
{
- var expectedHpdid = "expected";
var expectedCpn = "cpn";
var expectedPlrRecords = new[]
{
@@ -118,17 +99,9 @@ public async void GetEndorsementData_OneEndorsementWithCpn_MatchingHpdidWithLice
StatusReasonCode = "StatusReasonCode2"
}
};
- this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid"));
- this.TestDb.Has(APartyWith(id: 2, hpdid: expectedHpdid, cpn: expectedCpn));
- this.TestDb.Has(new Endorsement
- {
- Active = true,
- EndorsementRelationships = new[]
- {
- new EndorsementRelationship { PartyId = 1 },
- new EndorsementRelationship { PartyId = 2 }
- }
- });
+ this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid@bcsc"));
+ var otherParty = this.TestDb.Has(APartyWith(id: 2, hpdid: "otherHpdid@bcsc", cpn: expectedCpn));
+ this.TestDb.Has(AnEndorsementBetween(1, 2));
var query = new EndorsementData.Query { Hpdid = "hpdid" };
var client = A.Fake();
A.CallTo(() => client.GetRecordsAsync(expectedCpn))
@@ -141,62 +114,42 @@ public async void GetEndorsementData_OneEndorsementWithCpn_MatchingHpdidWithLice
Assert.Single(result.Value);
var model = result.Value.Single();
- Assert.Equal(expectedHpdid, model.Hpdid);
+ AssertBasicInfoMatches(otherParty, model);
Assert.NotNull(model.Licences);
AssertThat.CollectionsAreEquivalent(expectedPlrRecords, model.Licences, RecordModelPredicate);
}
[Fact]
- public async void GetEndorsementData_TwoEndorsementsWithCpn_MatchingHpdidsWithLicences()
+ public async Task GetEndorsementData_TwoEndorsementsWithCpn_MatchingHpdidsWithLicences()
{
- var expectedHpdid1 = "expected1";
- var expectedHpdid2 = "expected2";
- var expectedCpn1 = "cpn";
- var expectedPlrRecords1 = new[]
+ var expectedCpn = "cpn";
+ var expectedPlrRecords = new[]
{
new PlrRecord
{
- Cpn = expectedCpn1,
+ Cpn = expectedCpn,
IdentifierType = "IdentifierType1",
StatusCode = "StatusCode1",
StatusReasonCode = "StatusReasonCode1"
},
new PlrRecord
{
- Cpn = expectedCpn1,
+ Cpn = expectedCpn,
IdentifierType = "IdentifierType2",
StatusCode = "StatusCode2",
StatusReasonCode = "StatusReasonCode2"
}
};
- this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid"));
- this.TestDb.Has(APartyWith(id: 2, hpdid: expectedHpdid1, cpn: expectedCpn1));
- this.TestDb.Has(APartyWith(id: 3, hpdid: expectedHpdid2));
- this.TestDb.Has(new Endorsement
- {
- Active = true,
- EndorsementRelationships = new[]
- {
- new EndorsementRelationship { PartyId = 1 },
- new EndorsementRelationship { PartyId = 2 }
- }
- });
- this.TestDb.Has(new Endorsement
- {
- Active = true,
- EndorsementRelationships = new[]
- {
- new EndorsementRelationship { PartyId = 1 },
- new EndorsementRelationship { PartyId = 3 }
- }
- });
+ this.TestDb.Has(APartyWith(id: 1, hpdid: "hpdid@bcsc"));
+ var licencedOtherParty = this.TestDb.Has(APartyWith(id: 2, hpdid: "otherHpdid@bcsc", cpn: expectedCpn));
+ var unlicencedOtherParty = this.TestDb.Has(APartyWith(id: 3, hpdid: "otherHpdid2@bcsc"));
+ this.TestDb.Has(AnEndorsementBetween(1, 2));
+ this.TestDb.Has(AnEndorsementBetween(1, 3));
var query = new EndorsementData.Query { Hpdid = "hpdid" };
var client = A.Fake();
- A.CallTo(() => client.GetRecordsAsync(expectedCpn1, null))
- .Returns(expectedPlrRecords1);
- A.CallTo(() => client.GetRecordsAsync(expectedCpn1))
- .Returns(expectedPlrRecords1);
+ A.CallTo(() => client.GetRecordsAsync(expectedCpn, null))
+ .Returns(expectedPlrRecords);
var handler = this.MockDependenciesFor(client);
var result = await handler.HandleAsync(query);
@@ -204,13 +157,16 @@ public async void GetEndorsementData_TwoEndorsementsWithCpn_MatchingHpdidsWithLi
Assert.True(result.IsSuccess);
Assert.Equal(2, result.Value.Count);
- var found = result.Value.SingleOrDefault(res => res.Hpdid == expectedHpdid1);
+ var found = result.Value.SingleOrDefault(res => res.Hpdid == licencedOtherParty.Credentials.Single().Hpdid);
Assert.NotNull(found);
- AssertThat.CollectionsAreEquivalent(expectedPlrRecords1, found!.Licences, RecordModelPredicate);
+ AssertBasicInfoMatches(licencedOtherParty, found);
+ AssertThat.CollectionsAreEquivalent(expectedPlrRecords, found.Licences, RecordModelPredicate);
- found = result.Value.SingleOrDefault(res => res.Hpdid == expectedHpdid2);
+ found = result.Value.SingleOrDefault(res => res.Hpdid == unlicencedOtherParty.Credentials.Single().Hpdid);
Assert.NotNull(found);
- AssertThat.CollectionsAreEquivalent(Array.Empty(), found!.Licences, RecordModelPredicate);
+ AssertBasicInfoMatches(unlicencedOtherParty, found);
+ Assert.NotNull(found.Licences);
+ Assert.Empty(found.Licences);
}
public static Party APartyWith(int id, string hpdid, string? cpn = null)
@@ -219,14 +175,38 @@ public static Party APartyWith(int id, string hpdid, string? cpn = null)
{
Id = id,
Cpn = cpn,
- Credentials = new List
- {
+ FirstName = $"First{id}",
+ LastName = $"Last{id}",
+ Email = $"email@{id}.com",
+ Credentials =
+ [
new Credential
{
IdentityProvider = IdentityProviders.BCServicesCard,
IdpId = hpdid
}
- }
+ ]
};
}
+
+ public static Endorsement AnEndorsementBetween(int partyId1, int partyId2, bool isActive = true)
+ {
+ return new Endorsement
+ {
+ Active = isActive,
+ EndorsementRelationships =
+ [
+ new EndorsementRelationship { PartyId = partyId1 },
+ new EndorsementRelationship { PartyId = partyId2 }
+ ]
+ };
+ }
+
+ private static void AssertBasicInfoMatches(Party expected, EndorsementData.Model actual)
+ {
+ Assert.Equal(expected.Credentials.Single().Hpdid, actual.Hpdid);
+ Assert.Equal(expected.FirstName, actual.FirstName);
+ Assert.Equal(expected.LastName, actual.LastName);
+ Assert.Equal(expected.Email, actual.Email);
+ }
}
diff --git a/backend/webapi/Features/ThirdPartyIntegrations/EndorsementData.cs b/backend/webapi/Features/ThirdPartyIntegrations/EndorsementData.cs
index 49263ed61..8f5b3ce29 100644
--- a/backend/webapi/Features/ThirdPartyIntegrations/EndorsementData.cs
+++ b/backend/webapi/Features/ThirdPartyIntegrations/EndorsementData.cs
@@ -5,8 +5,8 @@ namespace Pidp.Features.ThirdPartyIntegrations;
using Microsoft.EntityFrameworkCore;
using Pidp.Data;
+using Pidp.Extensions;
using Pidp.Infrastructure.HttpClients.Plr;
-using Pidp.Models;
// Currently used by DMFT
public class EndorsementData
@@ -18,8 +18,11 @@ public class Query : IQuery>>
public class Model
{
- public string? Hpdid { get; set; } = string.Empty;
- public List Licences { get; set; } = new();
+ public string? Hpdid { get; set; }
+ public string FirstName { get; set; } = string.Empty;
+ public string LastName { get; set; } = string.Empty;
+ public string Email { get; set; } = string.Empty;
+ public List Licences { get; set; } = [];
public class LicenceInformation
{
@@ -34,21 +37,19 @@ public class QueryValidator : AbstractValidator
public QueryValidator() => this.RuleFor(x => x.Hpdid).NotEmpty();
}
- public class QueryHandler : IQueryHandler>>
+ public class QueryHandler(IPlrClient client, PidpDbContext context) : IQueryHandler>>
{
- private readonly IPlrClient client;
- private readonly PidpDbContext context;
-
- public QueryHandler(IPlrClient client, PidpDbContext context)
- {
- this.client = client;
- this.context = context;
- }
+ private readonly IPlrClient client = client;
+ private readonly PidpDbContext context = context;
public async Task>> HandleAsync(Query query)
{
+ query.Hpdid = query.Hpdid.EndsWith("@bcsc", StringComparison.Ordinal)
+ ? query.Hpdid
+ : $"{query.Hpdid}@bcsc";
+
var partyId = await this.context.Credentials
- .Where(credential => credential.Hpdid!.Replace("@bcsc", "") == query.Hpdid)
+ .Where(credential => credential.Hpdid == query.Hpdid)
.Select(credential => credential.PartyId)
.SingleOrDefaultAsync();
@@ -57,16 +58,16 @@ public async Task>> HandleAsync(Query query)
return DomainResult.NotFound
- >();
}
- var dtos = await this.context.Endorsements
- .Where(endorsement => endorsement.Active
- && endorsement.EndorsementRelationships.Any(relationship => relationship.PartyId == partyId))
- .SelectMany(endorsement => endorsement.EndorsementRelationships)
- .Where(relationship => relationship.PartyId != partyId)
- .Select(relationship => new Dto
+ var dtos = await this.context.ActiveEndorsingParties(partyId)
+ .Select(party => new
{
- BcscCredential = relationship.Party!.Credentials
- .SingleOrDefault(credential => credential.IsBcServicesCard),
- Cpn = relationship.Party!.Cpn
+ Hpdid = party.Credentials
+ .SingleOrDefault(credential => credential.IsBcServicesCard)!
+ .IdpId,
+ party.Cpn,
+ party.FirstName,
+ party.LastName,
+ party.Email
})
.ToListAsync();
@@ -74,7 +75,10 @@ public async Task