From 724879b9942b4c6a6f878fee6bb7ebc90eb0a2c0 Mon Sep 17 00:00:00 2001 From: Emad <121242386+esdd1995@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:03:19 -0700 Subject: [PATCH] SPDBT-3127 #2 SolProprietorSWLAppOriginTypeCode - Rename enum (#1464) # Description This PR includes the following proposed change(s): - rename `repo.ApplicationOriginTypeCode => ApplicationOriginTypeEnum` --- src/Spd.Manager.Licence/BizLicAppContract.cs | 1 + .../Application/Contract.Application.cs | 2 +- .../BizLicApplication/Contract.cs | 3 ++- .../BizLicApplication/Mappings.cs | 15 +++++++++++++-- .../ControllingMemberCrcApplication/Contract.cs | 2 +- .../ControllingMemberCrcApplication/Mappings.cs | 4 ++-- .../PersonLicApplication/Contract.cs | 2 +- .../PersonLicApplication/Mappings.cs | 4 ++-- src/Spd.Resource.Repository/SharedContract.cs | 2 +- src/Spd.Resource.Repository/SharedMappingFuncs.cs | 4 ++-- 10 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/Spd.Manager.Licence/BizLicAppContract.cs b/src/Spd.Manager.Licence/BizLicAppContract.cs index d6aae3723..2378a4f04 100644 --- a/src/Spd.Manager.Licence/BizLicAppContract.cs +++ b/src/Spd.Manager.Licence/BizLicAppContract.cs @@ -73,6 +73,7 @@ public record BizLicAppResponse : BizLicenceApp public Guid? ExpiredLicenceId { get; set; } public bool? HasExpiredLicence { get; set; } public bool? ApplicantIsBizManager { get; set; } + public ApplicationOriginTypeCode SolProprietorSWLAppOriginTypeCode { get; set; } // Contains branding, insurance, registrar, security dog certificate and BC report documents public IEnumerable? DocumentInfos { get; set; } diff --git a/src/Spd.Resource.Repository/Application/Contract.Application.cs b/src/Spd.Resource.Repository/Application/Contract.Application.cs index 981d9fc34..f163b389e 100644 --- a/src/Spd.Resource.Repository/Application/Contract.Application.cs +++ b/src/Spd.Resource.Repository/Application/Contract.Application.cs @@ -64,7 +64,7 @@ public record ApplicationCreateCmd { public Guid OrgId { get; set; } public Guid? ParentOrgId { get; set; } - public ApplicationOriginTypeCode OriginTypeCode { get; set; } + public ApplicationOriginTypeEnum OriginTypeCode { get; set; } public string? GivenName { get; set; } public string? MiddleName1 { get; set; } public string? MiddleName2 { get; set; } diff --git a/src/Spd.Resource.Repository/BizLicApplication/Contract.cs b/src/Spd.Resource.Repository/BizLicApplication/Contract.cs index 0db842816..28610b392 100644 --- a/src/Spd.Resource.Repository/BizLicApplication/Contract.cs +++ b/src/Spd.Resource.Repository/BizLicApplication/Contract.cs @@ -17,7 +17,7 @@ public record BizLicApplication public WorkerLicenceTypeEnum WorkerLicenceTypeCode { get; set; } public ApplicationTypeEnum ApplicationTypeCode { get; set; } public BizTypeEnum? BizTypeCode { get; set; } - public ApplicationOriginTypeCode? ApplicationOriginTypeCode { get; set; } = Repository.ApplicationOriginTypeCode.Portal; + public ApplicationOriginTypeEnum? ApplicationOriginTypeCode { get; set; } = ApplicationOriginTypeEnum.Portal; public string? GivenName { get; set; } public string? MiddleName1 { get; set; } public string? MiddleName2 { get; set; } @@ -73,6 +73,7 @@ public record BizLicApplicationResp() : BizLicApplication public bool? HasExpiredLicence { get; set; } public Guid? SoleProprietorSWLAppId { get; set; } //sole proprietor swl appliation id, for sole proprietor combo flow public IEnumerable NonSwlControllingMemberCrcAppIds { get; set; } + public ApplicationOriginTypeEnum SolProprietorSWLAppOriginTypeCode { get; set; } } public record PrivateInvestigatorSwlContactInfo : ContactInfo diff --git a/src/Spd.Resource.Repository/BizLicApplication/Mappings.cs b/src/Spd.Resource.Repository/BizLicApplication/Mappings.cs index 58d1d32ee..c7e89ec0c 100644 --- a/src/Spd.Resource.Repository/BizLicApplication/Mappings.cs +++ b/src/Spd.Resource.Repository/BizLicApplication/Mappings.cs @@ -22,7 +22,7 @@ public Mappings() .ForMember(d => d.spd_businessmanagermiddlename2, opt => opt.MapFrom(s => s.ManagerMiddleName2)) .ForMember(d => d.spd_businessmanageremail, opt => opt.MapFrom(s => s.ManagerEmailAddress)) .ForMember(d => d.spd_businessmanagerphone, opt => opt.MapFrom(s => s.ManagerPhoneNumber)) - .ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset(s.ApplicationOriginTypeCode))) + .ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset(s.ApplicationOriginTypeCode))) .ForMember(d => d.spd_payer, opt => opt.MapFrom(s => (int)PayerPreferenceOptionSet.Applicant)) .ForMember(d => d.spd_businesstype, opt => opt.MapFrom(s => SharedMappingFuncs.GetBizType(s.BizTypeCode))) .ForMember(d => d.spd_requestdogs, opt => opt.MapFrom(s => SharedMappingFuncs.GetYesNo(s.UseDogs))) @@ -39,7 +39,7 @@ public Mappings() .ForMember(d => d.spd_identityconfirmed, opt => opt.MapFrom(s => SharedMappingFuncs.GetIdentityConfirmed(s.ApplicationOriginTypeCode, s.ApplicationTypeCode))) .ReverseMap() .ForMember(d => d.WorkerLicenceTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetServiceType(s._spd_servicetypeid_value))) - .ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum(s.spd_origin))) + .ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum(s.spd_origin))) .ForMember(d => d.ApplicationTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetLicenceApplicationTypeEnum(s.spd_licenceapplicationtype))) .ForMember(d => d.BizTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetBizTypeEnum(s.spd_businesstype))) .ForMember(d => d.LicenceTermCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetLicenceTermEnum(s.spd_licenceterm))) @@ -77,6 +77,7 @@ public Mappings() .ForMember(d => d.HasExpiredLicence, opt => opt.MapFrom(s => s.spd_CurrentExpiredLicenceId == null ? false : true)) .ForMember(d => d.PrivateInvestigatorSwlInfo, opt => opt.Ignore()) .ForMember(d => d.SoleProprietorSWLAppId, opt => opt.MapFrom(s => GetSwlAppId(s.spd_businessapplication_spd_workerapplication.ToList()))) + .ForMember(d => d.SolProprietorSWLAppOriginTypeCode, opt => opt.MapFrom(s => GetSwlAppOrigin(s.spd_businessapplication_spd_workerapplication.ToList()))) .ForMember(d => d.NonSwlControllingMemberCrcAppIds, opt => opt.MapFrom(s => GetNonSwlCmAppIds(s.spd_businessapplication_spd_workerapplication.ToList()))) .IncludeBase(); @@ -119,6 +120,16 @@ private static bool IsApplicantBizManager(spd_application application) .OrderByDescending(a => a.createdon) .FirstOrDefault()?.spd_applicationid; } + private static ApplicationOriginTypeEnum? GetSwlAppOrigin(List apps) + { + Guid? swlServiceTypeId = DynamicsContextLookupHelpers.GetServiceTypeGuid(ServiceTypeEnum.SecurityWorkerLicence.ToString()); + //is it valid query? + int? spd_origin = apps.Where(a => a._spd_servicetypeid_value == swlServiceTypeId) + .OrderByDescending(a => a.createdon) + .FirstOrDefault()?.spd_origin; + + return SharedMappingFuncs.GetEnum(spd_origin); + } private static IEnumerable GetNonSwlCmAppIds(List apps) { diff --git a/src/Spd.Resource.Repository/ControllingMemberCrcApplication/Contract.cs b/src/Spd.Resource.Repository/ControllingMemberCrcApplication/Contract.cs index 2f76f2302..c67e65914 100644 --- a/src/Spd.Resource.Repository/ControllingMemberCrcApplication/Contract.cs +++ b/src/Spd.Resource.Repository/ControllingMemberCrcApplication/Contract.cs @@ -14,7 +14,7 @@ public record ControllingMemberCrcApplication { public WorkerLicenceTypeEnum WorkerLicenceTypeCode { get; set; } public ApplicationTypeEnum ApplicationTypeCode { get; set; } - public ApplicationOriginTypeCode? ApplicationOriginTypeCode { get; set; } = Repository.ApplicationOriginTypeCode.Portal; + public ApplicationOriginTypeEnum? ApplicationOriginTypeCode { get; set; } = ApplicationOriginTypeEnum.Portal; public Guid? ParentBizLicApplicationId { get; set; } public string? GivenName { get; set; } public string? MiddleName1 { get; set; } diff --git a/src/Spd.Resource.Repository/ControllingMemberCrcApplication/Mappings.cs b/src/Spd.Resource.Repository/ControllingMemberCrcApplication/Mappings.cs index d83a3d4ab..4e250ab57 100644 --- a/src/Spd.Resource.Repository/ControllingMemberCrcApplication/Mappings.cs +++ b/src/Spd.Resource.Repository/ControllingMemberCrcApplication/Mappings.cs @@ -60,7 +60,7 @@ public Mappings() .ForMember(d => d.spd_lastname, opt => opt.MapFrom(s => s.Surname)) .ForMember(d => d.spd_middlename1, opt => opt.MapFrom(s => s.MiddleName1)) .ForMember(d => d.spd_middlename2, opt => opt.MapFrom(s => s.MiddleName2)) - .ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset(s.ApplicationOriginTypeCode))) + .ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset(s.ApplicationOriginTypeCode))) .ForMember(d => d.spd_payer, opt => opt.MapFrom(s => (int)PayerPreferenceOptionSet.Organization)) .ForMember(d => d.spd_dateofbirth, opt => opt.MapFrom(s => SharedMappingFuncs.GetDateFromDateOnly(s.DateOfBirth))) .ForMember(d => d.spd_sex, opt => opt.MapFrom(s => SharedMappingFuncs.GetGender(s.GenderCode))) @@ -93,7 +93,7 @@ public Mappings() .ForMember(d => d.spd_identityconfirmed, opt => opt.MapFrom(s => SharedMappingFuncs.GetIdentityConfirmed(s.ApplicationOriginTypeCode, s.ApplicationTypeCode))) .ReverseMap() .ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.spd_emailaddress1)) - .ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum(s.spd_origin))) + .ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum(s.spd_origin))) .ForMember(d => d.DateOfBirth, opt => opt.MapFrom(s => SharedMappingFuncs.GetDateOnly(s.spd_dateofbirth))) .ForMember(d => d.GivenName, opt => opt.MapFrom(s => s.spd_firstname)) .ForMember(d => d.Surname, opt => opt.MapFrom(s => s.spd_lastname)) diff --git a/src/Spd.Resource.Repository/PersonLicApplication/Contract.cs b/src/Spd.Resource.Repository/PersonLicApplication/Contract.cs index 1594161cc..e68ed8c61 100644 --- a/src/Spd.Resource.Repository/PersonLicApplication/Contract.cs +++ b/src/Spd.Resource.Repository/PersonLicApplication/Contract.cs @@ -15,7 +15,7 @@ public record LicenceApplication { public WorkerLicenceTypeEnum WorkerLicenceTypeCode { get; set; } public ApplicationTypeEnum ApplicationTypeCode { get; set; } - public ApplicationOriginTypeCode? ApplicationOriginTypeCode { get; set; } = Repository.ApplicationOriginTypeCode.Portal; + public ApplicationOriginTypeEnum? ApplicationOriginTypeCode { get; set; } = Repository.ApplicationOriginTypeEnum.Portal; public BizTypeEnum? BizTypeCode { get; set; } public string? GivenName { get; set; } public string? MiddleName1 { get; set; } diff --git a/src/Spd.Resource.Repository/PersonLicApplication/Mappings.cs b/src/Spd.Resource.Repository/PersonLicApplication/Mappings.cs index d9cd22155..2b49427cb 100644 --- a/src/Spd.Resource.Repository/PersonLicApplication/Mappings.cs +++ b/src/Spd.Resource.Repository/PersonLicApplication/Mappings.cs @@ -71,7 +71,7 @@ public Mappings() .ForMember(d => d.spd_lastname, opt => opt.MapFrom(s => s.Surname)) .ForMember(d => d.spd_middlename1, opt => opt.MapFrom(s => s.MiddleName1)) .ForMember(d => d.spd_middlename2, opt => opt.MapFrom(s => s.MiddleName2)) - .ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset(s.ApplicationOriginTypeCode))) + .ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset(s.ApplicationOriginTypeCode))) .ForMember(d => d.spd_payer, opt => opt.MapFrom(s => (int)PayerPreferenceOptionSet.Applicant)) .ForMember(d => d.spd_dateofbirth, opt => opt.MapFrom(s => SharedMappingFuncs.GetDateFromDateOnly(s.DateOfBirth))) .ForMember(d => d.spd_sex, opt => opt.MapFrom(s => SharedMappingFuncs.GetGender(s.GenderCode))) @@ -146,7 +146,7 @@ public Mappings() .ForMember(d => d.GenderCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetGenderEnum(s.spd_sex))) .ForMember(d => d.BizTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetBizTypeEnum(s.spd_businesstype))) .ForMember(d => d.LicenceTermCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetLicenceTermEnum(s.spd_licenceterm))) - .ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum(s.spd_origin))) + .ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum(s.spd_origin))) .ForMember(d => d.HasCriminalHistory, opt => opt.MapFrom(s => SharedMappingFuncs.GetBool(s.spd_criminalhistory))) .ForMember(d => d.HairColourCode, opt => opt.MapFrom(s => GetHairColorEnum(s.spd_applicanthaircolour))) .ForMember(d => d.EyeColourCode, opt => opt.MapFrom(s => GetEyeColorEnum(s.spd_applicanteyecolour))) diff --git a/src/Spd.Resource.Repository/SharedContract.cs b/src/Spd.Resource.Repository/SharedContract.cs index 83226d374..04317499d 100644 --- a/src/Spd.Resource.Repository/SharedContract.cs +++ b/src/Spd.Resource.Repository/SharedContract.cs @@ -164,7 +164,7 @@ public enum ApplicationInviteStatusEnum Expired } -public enum ApplicationOriginTypeCode +public enum ApplicationOriginTypeEnum { Portal, Email, diff --git a/src/Spd.Resource.Repository/SharedMappingFuncs.cs b/src/Spd.Resource.Repository/SharedMappingFuncs.cs index 09f553ca1..582ba2cd7 100644 --- a/src/Spd.Resource.Repository/SharedMappingFuncs.cs +++ b/src/Spd.Resource.Repository/SharedMappingFuncs.cs @@ -205,9 +205,9 @@ internal static IEnumerable GetUploadedDocumentEnums(strin return Enum.Parse( DynamicsContextLookupHelpers.RoleGuidDictionary.FirstOrDefault(x => x.Value == role.spd_roleid).Key); } - internal static bool GetIdentityConfirmed(ApplicationOriginTypeCode? origin, ApplicationTypeEnum type) + internal static bool GetIdentityConfirmed(ApplicationOriginTypeEnum? origin, ApplicationTypeEnum type) { - bool isNotPortal = origin != ApplicationOriginTypeCode.Portal; + bool isNotPortal = origin != ApplicationOriginTypeEnum.Portal; bool isNewOrRenewal = type == ApplicationTypeEnum.New || type == ApplicationTypeEnum.Renewal;