diff --git a/GetIntoTeachingApi/Models/Crm/Validators/CandidateValidator.cs b/GetIntoTeachingApi/Models/Crm/Validators/CandidateValidator.cs index 96b0de480..8f2e3b7fd 100644 --- a/GetIntoTeachingApi/Models/Crm/Validators/CandidateValidator.cs +++ b/GetIntoTeachingApi/Models/Crm/Validators/CandidateValidator.cs @@ -57,10 +57,11 @@ public CandidateValidator(IStore store, IDateTimeProvider dateTime) RuleFor(candidate => candidate.InitialTeacherTrainingYearId) .SetValidator(new PickListItemIdValidator("contact", "dfe_ittyear", store)) .Unless(candidate => candidate.InitialTeacherTrainingYearId == null); - // RuleFor(candidate => candidate.ChannelId) - // .NotNull() - // .When(candidate => candidate.Id == null) - // .SetValidator(new PickListItemIdValidator("contact", "dfe_channelcreation", store)); + RuleFor(candidate => candidate.ChannelId) + .NotNull() + .When(candidate => candidate.Id == null) + .When(candidate => !candidate.ContactChannelCreations.Any()) + .SetValidator(new PickListItemIdValidator("contact", "dfe_channelcreation", store)); RuleFor(candidate => candidate.HasGcseEnglishId) .SetValidator(new PickListItemIdValidator("contact", "dfe_websitehasgcseenglish", store)) .Unless(candidate => candidate.HasGcseEnglishId == null); diff --git a/GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs b/GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs index 0dbbaaa63..d3c39ca7c 100644 --- a/GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs +++ b/GetIntoTeachingApiTests/Jobs/UpsertCandidateJobTests.cs @@ -135,7 +135,7 @@ private static bool IsMatch(object objectA, object objectB) private static string Signature(Candidate candidate) { - var changedProperties = "MergedIsNewRegistrantTeachingEventRegistrationsQualificationsPastTeachingPositionsApplicationFormsSchoolExperiencesIdEmail"; + var changedProperties = "MergedIsNewRegistrantTeachingEventRegistrationsQualificationsPastTeachingPositionsApplicationFormsSchoolExperiencesContactChannelCreationsIdEmail"; return $"{candidate.Id}-{candidate.Email}-{changedProperties}"; } }