Skip to content

Commit

Permalink
SPDBT-3127 #2 SolProprietorSWLAppOriginTypeCode - Rename enum (#1464)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- rename `repo.ApplicationOriginTypeCode => ApplicationOriginTypeEnum`
  • Loading branch information
esdd1995 authored Oct 5, 2024
1 parent a7c821c commit 724879b
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/Spd.Manager.Licence/BizLicAppContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Document>? DocumentInfos { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 2 additions & 1 deletion src/Spd.Resource.Repository/BizLicApplication/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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<Guid> NonSwlControllingMemberCrcAppIds { get; set; }
public ApplicationOriginTypeEnum SolProprietorSWLAppOriginTypeCode { get; set; }
}

public record PrivateInvestigatorSwlContactInfo : ContactInfo
Expand Down
15 changes: 13 additions & 2 deletions src/Spd.Resource.Repository/BizLicApplication/Mappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationOriginTypeCode, ApplicationOriginOptionSet>(s.ApplicationOriginTypeCode)))
.ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset<ApplicationOriginTypeEnum, ApplicationOriginOptionSet>(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)))
Expand All @@ -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<ApplicationOriginOptionSet, ApplicationOriginTypeCode>(s.spd_origin)))
.ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum<ApplicationOriginOptionSet, ApplicationOriginTypeEnum>(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)))
Expand Down Expand Up @@ -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<spd_application, BizLicApplication>();

Expand Down Expand Up @@ -119,6 +120,16 @@ private static bool IsApplicantBizManager(spd_application application)
.OrderByDescending(a => a.createdon)
.FirstOrDefault()?.spd_applicationid;
}
private static ApplicationOriginTypeEnum? GetSwlAppOrigin(List<spd_application> 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<ApplicationOriginOptionSet, ApplicationOriginTypeEnum>(spd_origin);
}

private static IEnumerable<Guid> GetNonSwlCmAppIds(List<spd_application> apps)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationOriginTypeCode, ApplicationOriginOptionSet>(s.ApplicationOriginTypeCode)))
.ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset<ApplicationOriginTypeEnum, ApplicationOriginOptionSet>(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)))
Expand Down Expand Up @@ -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<ApplicationOriginOptionSet, ApplicationOriginTypeCode>(s.spd_origin)))
.ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum<ApplicationOriginOptionSet, ApplicationOriginTypeEnum>(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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions src/Spd.Resource.Repository/PersonLicApplication/Mappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationOriginTypeCode, ApplicationOriginOptionSet>(s.ApplicationOriginTypeCode)))
.ForMember(d => d.spd_origin, opt => opt.MapFrom(s => (int)SharedMappingFuncs.GetOptionset<ApplicationOriginTypeEnum, ApplicationOriginOptionSet>(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)))
Expand Down Expand Up @@ -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<ApplicationOriginOptionSet, ApplicationOriginTypeCode>(s.spd_origin)))
.ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum<ApplicationOriginOptionSet, ApplicationOriginTypeEnum>(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)))
Expand Down
2 changes: 1 addition & 1 deletion src/Spd.Resource.Repository/SharedContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public enum ApplicationInviteStatusEnum
Expired
}

public enum ApplicationOriginTypeCode
public enum ApplicationOriginTypeEnum
{
Portal,
Email,
Expand Down
4 changes: 2 additions & 2 deletions src/Spd.Resource.Repository/SharedMappingFuncs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ internal static IEnumerable<UploadedDocumentEnum> GetUploadedDocumentEnums(strin
return Enum.Parse<ContactRoleCode>(
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;

Expand Down

0 comments on commit 724879b

Please sign in to comment.