-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description This PR includes the following proposed change(s): - Reorg Manager - add training pipeline
- Loading branch information
1 parent
3a0a1a3
commit b9b81f7
Showing
75 changed files
with
534 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Spd.Manager.Common.ManagerContract; | ||
using Spd.Manager.Shared; | ||
|
||
namespace Spd.Engine.Search | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using MediatR; | ||
using Spd.Manager.Shared; | ||
using Spd.Utilities.LogonUser; | ||
|
||
namespace Spd.Manager.Licence | ||
{ | ||
public interface IUserProfileManager | ||
{ | ||
public Task<OrgUserProfileResponse> Handle(GetCurrentUserProfileQuery request, CancellationToken ct); | ||
public Task<ApplicantProfileResponse> Handle(GetApplicantProfileQuery request, CancellationToken ct); | ||
public Task<ApplicantProfileResponse> Handle(ManageApplicantProfileCommand request, CancellationToken ct); //used for worker licensing portal | ||
} | ||
|
||
#region UserProfile | ||
public record GetCurrentUserProfileQuery(PortalUserIdentity PortalUserIdentity) : IRequest<OrgUserProfileResponse>; | ||
|
||
public class OrgUserProfileResponse | ||
{ | ||
public Guid? UserGuid { get; set; }//from token | ||
public string? UserDisplayName { get; set; } //from token | ||
public IdentityProviderTypeCode? IdentityProviderType { get; set; } | ||
public IEnumerable<UserInfo> UserInfos { get; set; } = Array.Empty<UserInfo>(); | ||
} | ||
|
||
public record UserInfo | ||
{ | ||
public Guid UserId { get; set; }//from spd, portal user id | ||
public string FirstName { get; set; } = null!; | ||
public string LastName { get; set; } = null!; | ||
public string? Email { get; set; } | ||
//public ContactAuthorizationTypeCode? ContactAuthorizationTypeCode { get; set; } = null;//from spd | ||
public OrgSettings? OrgSettings { get; set; } | ||
public Guid? OrgId { get; set; } | ||
public Guid? OrgRegistrationId { get; set; } = null; | ||
//public OrgRegistrationStatusCode? OrgRegistrationStatusCode { get; set; } = null; | ||
public string? OrgRegistrationNumber { get; set; } = null; | ||
public string? OrgName { get; set; } | ||
public Guid? UserGuid { get; set; } | ||
public UserInfoMsgTypeCode? UserInfoMsgType { get; set; } | ||
} | ||
|
||
public enum UserInfoMsgTypeCode | ||
{ | ||
REGISTRATION_DENIED, | ||
ACCOUNT_NOT_MATCH_RECORD, | ||
NO_ACTIVE_ACCOUNT_FOR_ORG | ||
} | ||
|
||
public record OrgSettings | ||
{ | ||
public PayerPreferenceTypeCode PayerPreference { get; set; } | ||
public BooleanTypeCode ContractorsNeedVulnerableSectorScreening { get; set; } | ||
public BooleanTypeCode LicenseesNeedVulnerableSectorScreening { get; set; } | ||
public bool GenericUploadEnabled { get; set; } | ||
} | ||
|
||
public class PortalUserIdentity | ||
{ | ||
public string? BCeIDUserName { get; set; } | ||
public string? DisplayName { get; set; } | ||
public string? FirstName { get; set; } | ||
public string? LastName { get; set; } | ||
public string? PreferredUserName { get; set; } | ||
public Guid? UserGuid { get; set; } | ||
public Guid BizGuid { get; set; } | ||
public string? BizName { get; set; } | ||
public string? Issuer { get; set; } | ||
public bool? EmailVerified { get; set; } | ||
public string? Email { get; set; } | ||
} | ||
#endregion | ||
|
||
#region ApplicantProfile | ||
public record GetApplicantProfileQuery(string BcscSub) : IRequest<ApplicantProfileResponse>; | ||
public class ApplicantProfileResponse | ||
{ | ||
public Guid ApplicantId { get; set; } //which is contact id in db | ||
public string? FirstName { get; set; } // which is contact firstname | ||
public string? LastName { get; set; } // which is contact lastname | ||
public string? Email { get; set; } | ||
public GenderCode? Gender { get; set; } | ||
public string Sub { get; set; } = null!; | ||
public DateOnly BirthDate { get; set; } | ||
public string? MiddleName1 { get; set; } | ||
public string? MiddleName2 { get; set; } | ||
public IdentityProviderTypeCode IdentityProviderTypeCode { get; set; } = IdentityProviderTypeCode.BcServicesCard; | ||
public Address? ResidentialAddress { get; set; } | ||
} | ||
public record ManageApplicantProfileCommand(BcscIdentityInfo BcscIdentityInfo) : IRequest<ApplicantProfileResponse>; | ||
|
||
#endregion | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
using AutoMapper; | ||
using MediatR; | ||
using Microsoft.Extensions.Logging; | ||
using Spd.Manager.Shared; | ||
using Spd.Resource.Applicants.Application; | ||
using Spd.Resource.Applicants.Contact; | ||
using Spd.Resource.Applicants.PortalUser; | ||
using Spd.Resource.Organizations.Identity; | ||
using Spd.Resource.Organizations.Org; | ||
using Spd.Resource.Organizations.Registration; | ||
using Spd.Resource.Organizations.User; | ||
|
||
namespace Spd.Manager.Licence | ||
{ | ||
internal class UserProfileManager | ||
: IRequestHandler<GetCurrentUserProfileQuery, OrgUserProfileResponse>, | ||
IRequestHandler<GetApplicantProfileQuery, ApplicantProfileResponse>, | ||
IRequestHandler<ManageApplicantProfileCommand, ApplicantProfileResponse>, | ||
IUserProfileManager | ||
{ | ||
private readonly IOrgUserRepository _orgUserRepository; | ||
private readonly IIdentityRepository _idRepository; | ||
private readonly IOrgRepository _orgRepository; | ||
private readonly IPortalUserRepository _portalUserRepository; | ||
private readonly IContactRepository _contactRepository; | ||
private readonly IMapper _mapper; | ||
private readonly ILogger<IUserProfileManager> _logger; | ||
|
||
public UserProfileManager( | ||
IOrgUserRepository orgUserRepository, | ||
IIdentityRepository idRepository, | ||
IOrgRepository orgRepository, | ||
IPortalUserRepository portalUserRepository, | ||
IContactRepository contactRepository, | ||
IMapper mapper, | ||
ILogger<IUserProfileManager> logger) | ||
{ | ||
_orgUserRepository = orgUserRepository; | ||
_idRepository = idRepository; | ||
_orgRepository = orgRepository; | ||
_mapper = mapper; | ||
_logger = logger; | ||
_portalUserRepository = portalUserRepository; | ||
_contactRepository = contactRepository; | ||
} | ||
|
||
public async Task<OrgUserProfileResponse> Handle(GetCurrentUserProfileQuery request, CancellationToken ct) | ||
{ | ||
Guid orgGuid = request.PortalUserIdentity.BizGuid; | ||
Guid? userGuid = request.PortalUserIdentity.UserGuid; | ||
List<UserInfo> userInfos = new(); | ||
|
||
//get all orgs | ||
var orgResult = (OrgsQryResult)await _orgRepository.QueryOrgAsync( | ||
new OrgsQry(orgGuid, ServiceTypes: IApplicationRepository.ScreeningServiceTypes), | ||
ct); | ||
foreach (OrgResult org in orgResult.OrgResults) | ||
{ | ||
UserInfo ui = new UserInfo(); | ||
var orgUsers = (OrgUsersResult)await _orgUserRepository.QueryOrgUserAsync(new OrgUsersSearch(org.Id), ct); | ||
var u = orgUsers.UserResults.FirstOrDefault(u => u.UserGuid == userGuid && u.IsActive); | ||
if (u != null) | ||
ui = _mapper.Map<UserInfo>(u); | ||
else | ||
ui = new UserInfo() { UserInfoMsgType = UserInfoMsgTypeCode.NO_ACTIVE_ACCOUNT_FOR_ORG }; | ||
ui.OrgName = org.OrganizationName; | ||
ui.OrgId = org.Id; | ||
ui.OrgSettings = _mapper.Map<OrgSettings>(org); | ||
userInfos.Add(ui); | ||
} | ||
|
||
return new OrgUserProfileResponse() | ||
{ | ||
IdentityProviderType = IdentityProviderTypeCode.BusinessBceId, | ||
UserDisplayName = request.PortalUserIdentity.DisplayName, | ||
UserGuid = request.PortalUserIdentity.UserGuid, | ||
UserInfos = userInfos | ||
}; | ||
} | ||
|
||
public async Task<ApplicantProfileResponse> Handle(GetApplicantProfileQuery request, CancellationToken ct) | ||
{ | ||
var result = await _idRepository.Query(new IdentityQry(request.BcscSub, null, IdentityProviderTypeEnum.BcServicesCard), ct); | ||
return _mapper.Map<ApplicantProfileResponse>(result.Items.FirstOrDefault()); | ||
} | ||
|
||
public async Task<ApplicantProfileResponse> Handle(ManageApplicantProfileCommand cmd, CancellationToken ct) | ||
{ | ||
ContactResp contactResp = null; | ||
var result = await _idRepository.Query(new IdentityQry(cmd.BcscIdentityInfo.Sub, null, IdentityProviderTypeEnum.BcServicesCard), ct); | ||
|
||
if (result == null || !result.Items.Any()) //first time to use system | ||
{ | ||
//add identity | ||
var id = await _idRepository.Manage(new CreateIdentityCmd(cmd.BcscIdentityInfo.Sub, null, IdentityProviderTypeEnum.BcServicesCard), ct); | ||
CreateContactCmd createContactCmd = _mapper.Map<CreateContactCmd>(cmd); | ||
createContactCmd.IdentityId = id.Id; | ||
contactResp = await _contactRepository.ManageAsync(createContactCmd, ct); | ||
//add address | ||
} | ||
else | ||
{ | ||
Identity id = result.Items.FirstOrDefault(); | ||
if (id.ContactId != null) | ||
{ | ||
//depends on requirement, probably update later when user select "yes" in user profile for licensing portal. | ||
UpdateContactCmd updateContactCmd = _mapper.Map<UpdateContactCmd>(cmd); | ||
updateContactCmd.Id = (Guid)id.ContactId; | ||
updateContactCmd.IdentityId = id.Id; | ||
contactResp = await _contactRepository.ManageAsync(updateContactCmd, ct); | ||
} | ||
else | ||
{ | ||
//there is identity, but no contact | ||
CreateContactCmd createContactCmd = _mapper.Map<CreateContactCmd>(cmd); | ||
createContactCmd.IdentityId = id.Id; | ||
contactResp = await _contactRepository.ManageAsync(createContactCmd, ct); | ||
} | ||
//update address | ||
} | ||
|
||
return _mapper.Map<ApplicantProfileResponse>(contactResp); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using AutoMapper; | ||
using Spd.Resource.Applicants.Contact; | ||
using Spd.Resource.Organizations.Identity; | ||
using Spd.Resource.Organizations.Org; | ||
using Spd.Resource.Organizations.User; | ||
using Spd.Utilities.Shared.ResourceContracts; | ||
|
||
namespace Spd.Manager.Licence | ||
{ | ||
internal class UserProfileMappings : Profile | ||
{ | ||
public UserProfileMappings() | ||
{ | ||
CreateMap<OrgResult, OrgSettings>(); | ||
CreateMap<UserResult, UserInfo>() | ||
.ForMember(d => d.OrgName, opt => opt.Ignore()) | ||
.ForMember(d => d.OrgSettings, opt => opt.Ignore()) | ||
.ForMember(d => d.UserId, opt => opt.MapFrom(s => s.Id)) | ||
.ForMember(d => d.OrgRegistrationId, opt => opt.Ignore()) | ||
.ForMember(d => d.OrgId, opt => opt.MapFrom(s => s.OrganizationId)); | ||
|
||
CreateMap<Identity, ApplicantProfileResponse>() | ||
.ForMember(d => d.ApplicantId, opt => opt.MapFrom(s => s.ContactId)) | ||
.ForMember(d => d.Email, opt => opt.MapFrom(s => s.EmailAddress)) | ||
; | ||
|
||
CreateMap<ManageApplicantProfileCommand, CreateContactCmd>() | ||
.ForMember(d => d.Sub, opt => opt.MapFrom(s => s.BcscIdentityInfo.Sub)) | ||
.IncludeBase<ManageApplicantProfileCommand, ContactCmd>(); | ||
|
||
CreateMap<ManageApplicantProfileCommand, UpdateContactCmd>() | ||
.IncludeBase<ManageApplicantProfileCommand, ContactCmd>(); | ||
|
||
CreateMap<ManageApplicantProfileCommand, ContactCmd>() | ||
.ForMember(d => d.FirstName, opt => opt.MapFrom(s => s.BcscIdentityInfo.FirstName)) | ||
.ForMember(d => d.LastName, opt => opt.MapFrom(s => s.BcscIdentityInfo.LastName)) | ||
.ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.BcscIdentityInfo.Email)) | ||
.ForMember(d => d.MiddleName1, opt => opt.MapFrom(s => s.BcscIdentityInfo.MiddleName1)) | ||
.ForMember(d => d.MiddleName2, opt => opt.MapFrom(s => s.BcscIdentityInfo.MiddleName2)) | ||
.ForMember(d => d.BirthDate, opt => opt.MapFrom(s => s.BcscIdentityInfo.BirthDate)) | ||
.ForMember(d => d.Gender, opt => opt.MapFrom(s => GetGenderEnum(s.BcscIdentityInfo.Gender))); | ||
|
||
CreateMap<ContactResp, ApplicantProfileResponse>() | ||
.ForMember(d => d.ApplicantId, opt => opt.MapFrom(s => s.Id)); | ||
} | ||
|
||
public static GenderEnum? GetGenderEnum(string? bscsGender) | ||
{ | ||
if (bscsGender == null) return null; | ||
string? str = bscsGender?.ToLower(); | ||
GenderEnum? gender = str switch | ||
{ | ||
"female" => GenderEnum.F, | ||
"male" => GenderEnum.M, | ||
"diverse" => GenderEnum.U, | ||
_ => null, | ||
}; | ||
return gender; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.