Skip to content

Commit

Permalink
spdbt-3268, 3280 profile (#1723)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- spdbt-3268, 3280 profile
  • Loading branch information
peggy-quartech authored Nov 9, 2024
1 parent f22a489 commit 351d196
Show file tree
Hide file tree
Showing 10 changed files with 8,404 additions and 2,031 deletions.
8 changes: 7 additions & 1 deletion src/Spd.Manager.Licence/ApplicantProfileContract.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using MediatR;
using Spd.Manager.Shared;
using Spd.Resource.Repository;
using Spd.Utilities.LogonUser;

namespace Spd.Manager.Licence
Expand Down Expand Up @@ -63,7 +62,14 @@ public record Applicant
public string? OtherOfficerRole { get; set; }
public bool? IsTreatedForMHC { get; set; }
public bool? HasCriminalHistory { get; set; }
public HairColourCode? HairColourCode { get; set; }
public EyeColourCode? EyeColourCode { get; set; }
public int? Height { get; set; }
public HeightUnitCode? HeightUnitCode { get; set; }
public int? Weight { get; set; }
public WeightUnitCode? WeightUnitCode { get; set; }
}

public record ApplicantProfileResponse : Applicant
{
public Guid ApplicantId { get; set; } //which is contact id in db
Expand Down
2 changes: 1 addition & 1 deletion src/Spd.Manager.Licence/ApplicantProfileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public async Task<Unit> Handle(ApplicantUpdateCommand cmd, CancellationToken ct)
if (response.Any())
throw new ApiException(HttpStatusCode.BadRequest, "There is some application in progress, you cannot update your profile.");

await ValidateFilesAsync(cmd, ct);
//await ValidateFilesAsync(cmd, ct);

ContactResp contact = await _contactRepository.GetAsync(cmd.ApplicantId, ct);

Expand Down
7 changes: 7 additions & 0 deletions src/Spd.Resource.Repository/Contact/Contract.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Spd.Resource.Repository.Alias;
using Spd.Resource.Repository.PersonLicApplication;

namespace Spd.Resource.Repository.Contact
{
Expand Down Expand Up @@ -36,6 +37,12 @@ public record Contact
public bool? HasCriminalHistory { get; set; }
public string? CriminalChargeDescription { get; set; }
public string? BirthPlace { get; set; }
public HairColourEnum? HairColourCode { get; set; }
public EyeColourEnum? EyeColourCode { get; set; }
public int? Height { get; set; }
public HeightUnitEnum? HeightUnitCode { get; set; }
public int? Weight { get; set; }
public WeightUnitEnum? WeightUnitCode { get; set; }
}
public record ContactResp : Contact
{
Expand Down
15 changes: 12 additions & 3 deletions src/Spd.Resource.Repository/Contact/Mappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ public Mappings()
.ForMember(d => d.IsTreatedForMHC, opt => opt.MapFrom(s => SharedMappingFuncs.GetBool(s.spd_mentalhealthcondition)))
.ForMember(d => d.LicensingTermAgreedDateTime, opt => opt.MapFrom(s => s.spd_lastloggedinlicensingportal))
.ForMember(d => d.LastestScreeningLogin, opt => opt.MapFrom(s => s.spd_lastloggedinscreeningportal))
.ForMember(d => d.IsActive, opt => opt.MapFrom(s => s.statecode == DynamicsConstants.StateCode_Active));
.ForMember(d => d.IsActive, opt => opt.MapFrom(s => s.statecode == DynamicsConstants.StateCode_Active))
.ForMember(d => d.HairColourCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetHairColorEnum(s.spd_haircolour)))
.ForMember(d => d.EyeColourCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEyeColorEnum(s.spd_eyecolour)))
.ForMember(d => d.Height, opt => opt.MapFrom(s => SharedMappingFuncs.GetHeightNumber(s.spd_height)))
.ForMember(d => d.HeightUnitCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetHeightUnitCode(s.spd_height)))
.ForMember(d => d.Weight, opt => opt.MapFrom(s => SharedMappingFuncs.GetWeightNumber(s.spd_weight)))
.ForMember(d => d.WeightUnitCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetWeightUnitCode(s.spd_weight)));

_ = CreateMap<ContactCmd, contact>()
.ForMember(d => d.firstname, opt => opt.MapFrom(s => StringHelper.ToTitleCase(s.FirstName)))
Expand All @@ -55,15 +61,18 @@ public Mappings()
.ForMember(d => d.address2_country, opt => opt.MapFrom(s => s.ResidentialAddress == null ? null : s.ResidentialAddress.Country))
.ForMember(d => d.address2_stateorprovince, opt => opt.MapFrom(s => s.ResidentialAddress == null ? null : s.ResidentialAddress.Province))
.ForMember(d => d.address2_postalcode, opt => opt.MapFrom(s => s.ResidentialAddress == null ? null : s.ResidentialAddress.PostalCode))

.ForMember(d => d.spd_selfdisclosure, opt => opt.MapFrom(s => SharedMappingFuncs.GetYesNo(s.HasCriminalHistory)))
.ForMember(d => d.spd_selfdisclosuredetails, opt => opt.MapFrom(s => s.CriminalChargeDescription))
.ForMember(d => d.spd_peaceofficer, opt => opt.MapFrom(s => SharedMappingFuncs.GetYesNo(s.IsPoliceOrPeaceOfficer)))
.ForMember(d => d.spd_peaceofficerstatus, opt => opt.MapFrom(s => SharedMappingFuncs.GetPoliceRoleOptionSet(s.PoliceOfficerRoleCode)))
.ForMember(d => d.spd_peaceofficerother, opt => opt.MapFrom(s => s.OtherOfficerRole))
.ForMember(d => d.spd_mentalhealthcondition, opt => opt.MapFrom(s => SharedMappingFuncs.GetYesNo(s.IsTreatedForMHC)))
.ForMember(d => d.spd_lastloggedinlicensingportal, opt => opt.Ignore())
.ForMember(d => d.spd_lastloggedinscreeningportal, opt => opt.Ignore());
.ForMember(d => d.spd_lastloggedinscreeningportal, opt => opt.Ignore())
.ForMember(d => d.spd_haircolour, opt => opt.MapFrom(s => SharedMappingFuncs.GetHairColor(s.HairColourCode)))
.ForMember(d => d.spd_eyecolour, opt => opt.MapFrom(s => SharedMappingFuncs.GetEyeColor(s.EyeColourCode)))
.ForMember(d => d.spd_height, opt => opt.MapFrom(s => SharedMappingFuncs.GetHeightStr(s.Height, s.HeightUnitCode)))
.ForMember(d => d.spd_weight, opt => opt.MapFrom(s => SharedMappingFuncs.GetWeightStr(s.Weight, s.WeightUnitCode)));

_ = CreateMap<CreateContactCmd, contact>()
.ForMember(d => d.contactid, opt => opt.MapFrom(s => Guid.NewGuid()))
Expand Down
153 changes: 15 additions & 138 deletions src/Spd.Resource.Repository/PersonLicApplication/Mappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Spd.Resource.Repository.Alias;
using Spd.Utilities.Dynamics;
using Spd.Utilities.Shared.Tools;
using System.Text.RegularExpressions;

namespace Spd.Resource.Repository.PersonLicApplication;

Expand Down Expand Up @@ -41,6 +40,10 @@ public Mappings()
.ForMember(d => d.spd_peaceofficerstatus, opt => opt.MapFrom(s => SharedMappingFuncs.GetPoliceRoleOptionSet(s.PoliceOfficerRoleCode)))
.ForMember(d => d.spd_peaceofficerother, opt => opt.MapFrom(s => s.OtherOfficerRole))
.ForMember(d => d.spd_mentalhealthcondition, opt => opt.MapFrom(s => SharedMappingFuncs.GetYesNo(s.IsTreatedForMHC)))
.ForMember(d => d.spd_haircolour, opt => opt.MapFrom(s => SharedMappingFuncs.GetHairColor(s.HairColourCode)))
.ForMember(d => d.spd_eyecolour, opt => opt.MapFrom(s => SharedMappingFuncs.GetEyeColor(s.EyeColourCode)))
.ForMember(d => d.spd_height, opt => opt.MapFrom(s => SharedMappingFuncs.GetHeightStr(s.Height, s.HeightUnitCode)))
.ForMember(d => d.spd_weight, opt => opt.MapFrom(s => SharedMappingFuncs.GetWeightStr(s.Weight, s.WeightUnitCode)))
.ReverseMap()
.ForMember(d => d.DateOfBirth, opt => opt.MapFrom(s => SharedMappingFuncs.GetDateOnly(s.birthdate)))
.ForMember(d => d.GenderCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetGenderEnum(s.spd_sex)))
Expand Down Expand Up @@ -78,10 +81,10 @@ public Mappings()
.ForMember(d => d.spd_licenceterm, opt => opt.MapFrom(s => GetLicenceTerm(s.LicenceTermCode)))
.ForMember(d => d.spd_criminalhistory, opt => opt.MapFrom(s => SharedMappingFuncs.GetYesNo(s.HasCriminalHistory)))
.ForMember(d => d.spd_bcdriverslicense, opt => opt.MapFrom(s => s.BcDriversLicenceNumber))
.ForMember(d => d.spd_applicanthaircolour, opt => opt.MapFrom(s => GetHairColor(s.HairColourCode)))
.ForMember(d => d.spd_applicanteyecolour, opt => opt.MapFrom(s => GetEyeColor(s.EyeColourCode)))
.ForMember(d => d.spd_height, opt => opt.MapFrom(s => GetHeightStr(s)))
.ForMember(d => d.spd_weight, opt => opt.MapFrom(s => GetWeightStr(s)))
.ForMember(d => d.spd_applicanthaircolour, opt => opt.MapFrom(s => SharedMappingFuncs.GetHairColor(s.HairColourCode)))
.ForMember(d => d.spd_applicanteyecolour, opt => opt.MapFrom(s => SharedMappingFuncs.GetEyeColor(s.EyeColourCode)))
.ForMember(d => d.spd_height, opt => opt.MapFrom(s => SharedMappingFuncs.GetHeightStr(s.Height, s.HeightUnitCode)))
.ForMember(d => d.spd_weight, opt => opt.MapFrom(s => SharedMappingFuncs.GetWeightStr(s.Weight, s.WeightUnitCode)))
.ForMember(d => d.spd_emailaddress1, opt => opt.MapFrom(s => s.ContactEmailAddress))
.ForMember(d => d.spd_phonenumber, opt => opt.MapFrom(s => s.ContactPhoneNumber))
.ForMember(d => d.spd_addressline1, opt => opt.MapFrom(s => GetMailingAddress(s) == null ? null : GetMailingAddress(s).AddressLine1))
Expand All @@ -108,7 +111,7 @@ public Mappings()
.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)))
.ForMember(d => d.statecode, opt => opt.MapFrom(s => DynamicsConstants.StateCode_Active))
.ForMember(d => d.spd_requestdogsreasons, opt => opt.MapFrom(s => SharedMappingFuncs.GetDogReasonOptionSets(s.IsDogsPurposeDetectionDrugs,s.IsDogsPurposeProtection, s.IsDogsPurposeDetectionExplosives)))
.ForMember(d => d.spd_requestdogsreasons, opt => opt.MapFrom(s => SharedMappingFuncs.GetDogReasonOptionSets(s.IsDogsPurposeDetectionDrugs, s.IsDogsPurposeProtection, s.IsDogsPurposeDetectionExplosives)))
.ForMember(d => d.spd_submittedon, opt => opt.Ignore())
.ForMember(d => d.spd_declaration, opt => opt.MapFrom(s => s.AgreeToCompleteAndAccurate))
.ForMember(d => d.spd_consent, opt => opt.MapFrom(s => s.AgreeToCompleteAndAccurate))
Expand Down Expand Up @@ -148,16 +151,16 @@ public Mappings()
.ForMember(d => d.LicenceTermCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetLicenceTermEnum(s.spd_licenceterm)))
.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)))
.ForMember(d => d.HairColourCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetHairColorEnum(s.spd_applicanthaircolour)))
.ForMember(d => d.EyeColourCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEyeColorEnum(s.spd_applicanteyecolour)))
.ForMember(d => d.MailingAddressData, opt => opt.Ignore())
.ForMember(d => d.ResidentialAddressData, opt => opt.Ignore())
.ForMember(d => d.IsMailingTheSameAsResidential, opt => opt.Ignore())
.ForMember(d => d.Height, opt => opt.MapFrom(s => GetHeightNumber(s.spd_height)))
.ForMember(d => d.Height, opt => opt.MapFrom(s => SharedMappingFuncs.GetHeightNumber(s.spd_height)))
.ForMember(d => d.HasLegalNameChanged, opt => opt.MapFrom(s => SharedMappingFuncs.GetBool(s.spd_legalnamechange)))
.ForMember(d => d.HeightUnitCode, opt => opt.MapFrom(s => GetHeightUnitCode(s.spd_height)))
.ForMember(d => d.Weight, opt => opt.MapFrom(s => GetWeightNumber(s.spd_weight)))
.ForMember(d => d.WeightUnitCode, opt => opt.MapFrom(s => GetWeightUnitCode(s.spd_weight)))
.ForMember(d => d.HeightUnitCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetHeightUnitCode(s.spd_height)))
.ForMember(d => d.Weight, opt => opt.MapFrom(s => SharedMappingFuncs.GetWeightNumber(s.spd_weight)))
.ForMember(d => d.WeightUnitCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetWeightUnitCode(s.spd_weight)))
.ForMember(d => d.IsPoliceOrPeaceOfficer, opt => opt.MapFrom(s => SharedMappingFuncs.GetBool(s.spd_peaceofficer)))
.ForMember(d => d.IsTreatedForMHC, opt => opt.MapFrom(s => SharedMappingFuncs.GetBool(s.spd_mentalhealthcondition)))
.ForMember(d => d.IsDogsPurposeProtection, opt => opt.MapFrom(s => SharedMappingFuncs.GetDogReasonFlag(s.spd_requestdogsreasons, RequestDogPurposeOptionSet.Protection)))
Expand Down Expand Up @@ -224,31 +227,6 @@ public Mappings()
if (code == null) return null;
return (int)Enum.Parse<LicenceTermOptionSet>(code.ToString());
}

private static int? GetHairColor(HairColourEnum? code)
{
if (code == null) return null;
return (int)Enum.Parse<HairColorOptionSet>(code.ToString());
}

private static HairColourEnum? GetHairColorEnum(int? optionset)
{
if (optionset == null) return null;
return Enum.Parse<HairColourEnum>(Enum.GetName(typeof(HairColorOptionSet), optionset));
}

private static int? GetEyeColor(EyeColourEnum? code)
{
if (code == null) return null;
return (int)Enum.Parse<EyeColorOptionSet>(code.ToString());
}

private static EyeColourEnum? GetEyeColorEnum(int? optionset)
{
if (optionset == null) return null;
return Enum.Parse<EyeColourEnum>(Enum.GetName(typeof(EyeColorOptionSet), optionset));
}

private static Addr GetMailingAddress(LicenceApplication app)
{
//if residential address is the same as mailing address, fe will send an empty mailing address
Expand All @@ -258,105 +236,6 @@ private static Addr GetMailingAddress(LicenceApplication app)
return app.MailingAddressData;
}

private static string? GetWeightStr(LicenceApplication app)
{
if (app.WeightUnitCode != null)
{
return app.WeightUnitCode switch
{
WeightUnitEnum.Kilograms => app.Weight + "kg",
WeightUnitEnum.Pounds => app.Weight + "lb",
};
}
else
{
return app.Weight.ToString();
}
}

//str should be like 130lb or 65kg or lb or kg or 130
private static int? GetWeightNumber(string? str)
{
if (str == null) return null;
try
{
string temp = str.Replace("lb", string.Empty).Replace("kg", string.Empty);
return int.Parse(temp);
}
catch (Exception e)
{
return null;
}
}

//str should be like 130lb or 65kg or lb or kg or 130
private static WeightUnitEnum? GetWeightUnitCode(string? str)
{
if (str == null) return null;
try
{
string temp = Regex.Replace(str, @"\d", string.Empty);
if (temp == "kg") return WeightUnitEnum.Kilograms;
if (temp == "lb") return WeightUnitEnum.Pounds;
else
return null;
}
catch (Exception e)
{
return null;
}
}

private static string GetHeightStr(LicenceApplication app)
{
//if residential address is the same as mailing address, fe will send an empty mailing address
if (app.HeightUnitCode != null)
{
return app.HeightUnitCode switch
{
HeightUnitEnum.Centimeters => app.Height + "cm",
HeightUnitEnum.Inches => app.Height + "in", //todo: when ui decide what to use.
};
}
else
{
return app.Height.ToString();
}
}

//str should be like 130lb or 65kg or lb or kg or 130
private static int? GetHeightNumber(string? str)
{
if (str == null) return null;
try
{
string temp = str.Replace("cm", string.Empty).Replace("in", string.Empty);
return int.Parse(temp);
}
catch (Exception e)
{
return null;
}
}

//str should be like 130lb or 65kg or lb or kg or 130
private static HeightUnitEnum? GetHeightUnitCode(string? str)
{
if (str == null) return null;
try
{
string temp = Regex.Replace(str, @"\d", string.Empty);
if (temp == "in") return HeightUnitEnum.Inches;
if (temp == "cm") return HeightUnitEnum.Centimeters;
else
return null;
}
catch (Exception e)
{
return null;
}
}

private static MailingAddr? GetMailingAddressData(contact c)
{
MailingAddr mailingAddress = new();
Expand Down Expand Up @@ -414,7 +293,5 @@ private static string GetHeightStr(LicenceApplication app)
c.address1_postalcode == c.address2_postalcode;
}



}

4 changes: 4 additions & 0 deletions src/Spd.Resource.Repository/SharedContactFuncs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ private static contact UpdateExistingContact(contact existingContact, contact ne
existingContact.spd_selfdisclosuredetails = newContact.spd_selfdisclosuredetails ?? existingContact.spd_selfdisclosuredetails;
existingContact.spd_lastloggedinlicensingportal = newContact.spd_lastloggedinlicensingportal ?? existingContact.spd_lastloggedinlicensingportal;
existingContact.spd_lastloggedinscreeningportal = newContact.spd_lastloggedinscreeningportal ?? existingContact.spd_lastloggedinscreeningportal;
existingContact.spd_height = newContact.spd_height ?? existingContact.spd_height;
existingContact.spd_weight = newContact.spd_weight ?? existingContact.spd_weight;
existingContact.spd_eyecolour = newContact.spd_eyecolour ?? existingContact.spd_eyecolour;
existingContact.spd_haircolour = newContact.spd_haircolour ?? existingContact.spd_haircolour;
return existingContact;
}
}
Loading

0 comments on commit 351d196

Please sign in to comment.