diff --git a/src/Spd.Manager.Cases/Licence/Contract.cs b/src/Spd.Manager.Cases/Licence/Contract.cs index 7cf08d1ae..5d7045cbe 100644 --- a/src/Spd.Manager.Cases/Licence/Contract.cs +++ b/src/Spd.Manager.Cases/Licence/Contract.cs @@ -298,15 +298,9 @@ public class WorkerLicenceAppSubmitRequestValidator : AbstractValidator r.LicenceAppId) - .NotEmpty(); - - RuleFor(r => r.WorkerLicenceTypeCode) - .NotEmpty(); - - RuleFor(r => r.ApplicationTypeCode) - .NotEmpty(); - + RuleFor(r => r.LicenceAppId).NotEmpty(); + RuleFor(r => r.WorkerLicenceTypeCode).NotEmpty(); + RuleFor(r => r.ApplicationTypeCode).NotEmpty(); RuleFor(r => r.isSoleProprietor).NotEmpty(); RuleFor(r => r.Surname).NotEmpty(); RuleFor(r => r.DateOfBirth).NotEmpty(); @@ -314,17 +308,77 @@ public WorkerLicenceAppSubmitRequestValidator() RuleFor(r => r.LicenceTermCode).NotEmpty(); RuleFor(r => r.HasExpiredLicence).NotEmpty(); RuleFor(r => r.ExpiredLicenceNumber).NotEmpty().When(r => r.HasExpiredLicence == true); - RuleFor(r => r.IsCanadianCitizen).NotEmpty(); - RuleFor(r => r.CitizenshipDocument).NotEmpty(); + RuleFor(r => r.HasCriminalHistory).NotEmpty(); + RuleFor(r => r.HasBcDriversLicence).NotEmpty(); + RuleFor(r => r.HairColourCode).NotEmpty(); + RuleFor(r => r.EyeColourCode).NotEmpty(); + RuleFor(r => r.Height).NotEmpty(); + RuleFor(r => r.HeightUnitCode).NotEmpty(); + RuleFor(r => r.Weight).NotEmpty(); + RuleFor(r => r.WeightUnitCode).NotEmpty(); + RuleFor(r => r.HasCriminalHistory).NotEmpty(); + RuleFor(r => r.IsMailingTheSameAsResidential).NotEmpty(); + RuleFor(r => r.ContactPhoneNumber).MaximumLength(15).NotEmpty(); + RuleFor(r => r.ContactEmailAddress).MaximumLength(75).When(r => r.ContactEmailAddress != null); + + //police officer RuleFor(r => r.IsPoliceOrPeaceOfficer).NotEmpty(); RuleFor(r => r.PoliceOfficerRoleCode).NotEmpty().When(r => r.IsPoliceOrPeaceOfficer == true); + RuleFor(r => r.PoliceOfficerDocument).NotEmpty().When(r => r.IsPoliceOrPeaceOfficer == true); + RuleFor(r => r.PoliceOfficerDocument.LicenceDocumentTypeCode) + .Must(c => c == LicenceDocumentTypeCode.PoliceBackgroundLetterOfNoConflict) + .When(r => r.IsPoliceOrPeaceOfficer == true && r.PoliceOfficerDocument != null); + + //mental health + RuleFor(r => r.IsTreatedForMHC).NotEmpty(); + RuleFor(r => r.MentalHealthDocument).NotEmpty().When(r => r.IsTreatedForMHC == true); + RuleFor(r => r.MentalHealthDocument.LicenceDocumentTypeCode) + .Must(c => c == LicenceDocumentTypeCode.MentalHealthCondition) + .When(r => r.IsTreatedForMHC == true && r.MentalHealthDocument != null); + + //citizenship + RuleFor(r => r.IsCanadianCitizen).NotEmpty(); + RuleFor(r => r.CitizenshipDocument).NotEmpty(); RuleFor(r => r.CitizenshipDocument.LicenceDocumentTypeCode) .Must(c => LicenceManager.WorkProofCodes.Contains(c)) .When(r => r.CitizenshipDocument != null && r.IsCanadianCitizen == false); RuleFor(r => r.CitizenshipDocument.LicenceDocumentTypeCode) .Must(c => LicenceManager.CitizenshipProofCodes.Contains(c)) .When(r => r.CitizenshipDocument != null && r.IsCanadianCitizen == true); - //todo: add more validation when the ui design settled. + RuleFor(r => r.CitizenshipDocument.ExpiryDate) + .NotEmpty() + .Must(d => d > DateTimeOffset.Now) + .When(r => r.CitizenshipDocument != null && r.IsCanadianCitizen == false && (r.CitizenshipDocument.LicenceDocumentTypeCode == LicenceDocumentTypeCode.WorkPermit || r.CitizenshipDocument.LicenceDocumentTypeCode == LicenceDocumentTypeCode.StudyPermit)); + + //additional gov id + RuleFor(r => r.AdditionalGovIdDocument) + .NotEmpty() + .Must(c => LicenceManager.GovIdCodes.Contains(c.LicenceDocumentTypeCode)) + .When(r => r.CitizenshipDocument != null && (r.CitizenshipDocument.LicenceDocumentTypeCode != LicenceDocumentTypeCode.CanadianPassport && r.CitizenshipDocument.LicenceDocumentTypeCode != LicenceDocumentTypeCode.PermanentResidentCard)); + + //fingerprint + RuleFor(r => r.FingerprintProofDocument).NotEmpty(); + RuleFor(r => r.FingerprintProofDocument.LicenceDocumentTypeCode) + .Must(c => c == LicenceDocumentTypeCode.ProofOfFingerprint); + + //photo + RuleFor(r => r.UseBcServicesCardPhoto).NotEmpty(); + RuleFor(r => r.IdPhotoDocument).NotEmpty().When(r => r.UseBcServicesCardPhoto == false); + RuleFor(r => r.IdPhotoDocument.LicenceDocumentTypeCode) + .Must(c => c == LicenceDocumentTypeCode.PhotoOfYourself) + .When(r => r.UseBcServicesCardPhoto == false && r.IdPhotoDocument != null); + + //residential address + RuleFor(r => r.ResidentialAddressData).NotEmpty(); + RuleFor(r => r.ResidentialAddressData.Province).NotEmpty().When(r => r.ResidentialAddressData != null); + RuleFor(r => r.ResidentialAddressData.City).NotEmpty().MaximumLength(100).When(r => r.ResidentialAddressData != null); + RuleFor(r => r.ResidentialAddressData.AddressLine1).NotEmpty().MaximumLength(100).When(r => r.ResidentialAddressData != null); + RuleFor(r => r.ResidentialAddressData.Country).NotEmpty().MaximumLength(100).When(r => r.ResidentialAddressData != null); + RuleFor(r => r.ResidentialAddressData.PostalCode).NotEmpty().MaximumLength(20).When(r => r.ResidentialAddressData != null); + + //category + RuleFor(r => r.CategoryData).NotEmpty().Must(d => d.Count() > 0 && d.Count() < 7); + } } diff --git a/src/Spd.Manager.Cases/Licence/LicenceManager.Document.cs b/src/Spd.Manager.Cases/Licence/LicenceManager.Document.cs index 6b612d38f..2614938d0 100644 --- a/src/Spd.Manager.Cases/Licence/LicenceManager.Document.cs +++ b/src/Spd.Manager.Cases/Licence/LicenceManager.Document.cs @@ -353,7 +353,6 @@ private LicenceDocumentTypeCode GetlicenceDocumentTypeCode(DocumentTypeEnum docu LicenceDocumentTypeCode.WorkPermit, LicenceDocumentTypeCode.StudyPermit, LicenceDocumentTypeCode.DocumentToVerifyLegalWorkStatus, - LicenceDocumentTypeCode.CanadianCitizenship }; public static List CitizenshipProofCodes = new List { @@ -361,4 +360,12 @@ private LicenceDocumentTypeCode GetlicenceDocumentTypeCode(DocumentTypeEnum docu LicenceDocumentTypeCode.BirthCertificate, LicenceDocumentTypeCode.CertificateOfIndianStatus, }; + + public static List GovIdCodes = new List { + LicenceDocumentTypeCode.DriversLicence, + LicenceDocumentTypeCode.CanadianFirearmsLicence, + LicenceDocumentTypeCode.BcServicesCard, + LicenceDocumentTypeCode.CertificateOfIndianStatus, + LicenceDocumentTypeCode.GovernmentIssuedPhotoId + }; }