Skip to content

Commit

Permalink
Removed ContactChannelCreations object which encapsulated list of Con…
Browse files Browse the repository at this point in the history
…tactChannelCreation types given the attribute was masked from the underlying reflection property values extractor.
  • Loading branch information
spencerohegartyDfE committed Jan 22, 2025
1 parent 2702912 commit 2ae66ef
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 89 deletions.
6 changes: 3 additions & 3 deletions GetIntoTeachingApi/Models/Crm/Candidate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public enum RegistrationStatus
[EntityRelationship("dfe_contact_dfe_candidateschoolexperience_ContactId", typeof(CandidateSchoolExperience))]
public List<CandidateSchoolExperience> SchoolExperiences { get; set; } = new List<CandidateSchoolExperience>();
[EntityRelationship("dfe_contact_dfe_contactchannelcreation_ContactId", typeof(ContactChannelCreation))]
public ContactChannelCreations ContactChannelCreations { get; set; } = new ContactChannelCreations();
public List<ContactChannelCreation> ContactChannelCreations { get; set; } = new List<ContactChannelCreation>();

public Candidate() : base(){
}
Expand Down Expand Up @@ -344,7 +344,7 @@ public void ConfigureChannel(ICreateContactChannel contactChannelCreator, Guid?
{
ChannelId = null;
AddContactChannelCreation(
channelCreation: !ContactChannelCreations.HasExistingContactChannelCreations,
channelCreation: !ContactChannelCreations.Any(),
contactChannelCreator: contactChannelCreator);
}
else
Expand Down Expand Up @@ -378,7 +378,7 @@ public void ConfigureChannel(ICreateContactChannel contactChannelCreator, Guid?
/// </param>
private void AddContactChannelCreation(bool channelCreation, ICreateContactChannel contactChannelCreator)
{
ContactChannelCreations.AddContactChannelCreation(
ContactChannelCreations.Add(
ContactChannelCreation.Create(
creationChannel: channelCreation,
sourceId: contactChannelCreator.CreationChannelSourceId,
Expand Down
65 changes: 0 additions & 65 deletions GetIntoTeachingApi/Models/Crm/ContactChannelCreations.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public CandidateValidator(IStore store, IDateTimeProvider dateTime)
RuleFor(candidate => candidate.ChannelId)
.NotNull()
.When(candidate => candidate.Id == null)
.When(candidate => !candidate.ContactChannelCreations.HasExistingContactChannelCreations)
.When(candidate => !candidate.ContactChannelCreations.Any())
.SetValidator(new PickListItemIdValidator<Candidate>("contact", "dfe_channelcreation", store));
RuleFor(candidate => candidate.HasGcseEnglishId)
.SetValidator(new PickListItemIdValidator<Candidate>("contact", "dfe_websitehasgcseenglish", store))
Expand Down
4 changes: 2 additions & 2 deletions GetIntoTeachingApi/Services/CandidateUpserter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ private static IEnumerable<CandidateSchoolExperience> ClearSchoolExperiences(Can
private static IEnumerable<ContactChannelCreation> ClearContactChannelCreations(Candidate candidate)
{
List<ContactChannelCreation> contactChannelCreations =
new(candidate.ContactChannelCreations.GetContactChannelCreations());
candidate.ContactChannelCreations.Reset();
new(candidate.ContactChannelCreations);
candidate.ContactChannelCreations.Clear();

return contactChannelCreations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void ExistingCandidate_MapsCorrectly()
candidate.PrivacyPolicy.AcceptedPolicyId.Should().Be((Guid)request.AcceptedPolicyId);
candidate.PrivacyPolicy.AcceptedAt.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(30));

var contactChannelCreation = candidate.ContactChannelCreations.GetContactChannelCreations().First();
var contactChannelCreation = candidate.ContactChannelCreations.First();
contactChannelCreation.CreationChannel.Should().Be(false);
contactChannelCreation.CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
contactChannelCreation.CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
Expand All @@ -85,7 +85,7 @@ public void NewCandidate_MapsCorrectly()
CreationChannelActivityId = 222750001,
};

var contactChannelCreation = request.Candidate.ContactChannelCreations.GetContactChannelCreations().First();
var contactChannelCreation = request.Candidate.ContactChannelCreations.First();
contactChannelCreation.CreationChannel.Should().Be(true);
contactChannelCreation.CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
contactChannelCreation.CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void ExistingCandidate_MapsCorrectly()
candidate.Qualifications.First().TypeId.Should().Be((int)CandidateQualification.DegreeType.Degree);
candidate.Qualifications.First().Id.Should().Be(request.QualificationId);

var contactChannelCreation = candidate.ContactChannelCreations.GetContactChannelCreations().First();
var contactChannelCreation = candidate.ContactChannelCreations.First();
contactChannelCreation.CreationChannel.Should().Be(false);
contactChannelCreation.CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
contactChannelCreation.CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
Expand All @@ -135,7 +135,7 @@ public void NewCandidate_MapsCreationChannelCorrectly()
CreationChannelActivityId = 222750001,
};

var contactChannelCreation = request.Candidate.ContactChannelCreations.GetContactChannelCreations().First();
var contactChannelCreation = request.Candidate.ContactChannelCreations.First();
contactChannelCreation.CreationChannel.Should().Be(true);
contactChannelCreation.CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
contactChannelCreation.CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void ExistingCandidate_MapsCorrectly()
candidate.Qualifications.First().TypeId.Should().Be((int)CandidateQualification.DegreeType.Degree);
candidate.Qualifications.First().Id.Should().Be(request.QualificationId);

var contactChannelCreation = candidate.ContactChannelCreations.GetContactChannelCreations().First();
var contactChannelCreation = candidate.ContactChannelCreations.First();
contactChannelCreation.CreationChannel.Should().Be(false);
contactChannelCreation.CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
contactChannelCreation.CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
Expand All @@ -144,7 +144,7 @@ public void NewCandidate_MapsCorrectly()
CreationChannelActivityId = 222750001,
};

var contactChannelCreation = request.Candidate.ContactChannelCreations.GetContactChannelCreations().First();
var contactChannelCreation = request.Candidate.ContactChannelCreations.First();
contactChannelCreation.CreationChannel.Should().Be(true);
contactChannelCreation.CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
contactChannelCreation.CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void ExistingCandidate_MapsCorrectly()
candidate.PrivacyPolicy.AcceptedPolicyId.Should().Be((Guid)request.AcceptedPolicyId);
candidate.PrivacyPolicy.AcceptedAt.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(30));

var contactChannelCreation = candidate.ContactChannelCreations.GetContactChannelCreations().First();
var contactChannelCreation = candidate.ContactChannelCreations.First();
contactChannelCreation.CreationChannel.Should().Be(false);
contactChannelCreation.CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
contactChannelCreation.CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
Expand All @@ -125,7 +125,7 @@ public void NewCandidate_MapsCorrectly()
CreationChannelActivityId = 222750001,
};

var contactChannelCreation = request.Candidate.ContactChannelCreations.GetContactChannelCreations().First();
var contactChannelCreation = request.Candidate.ContactChannelCreations.First();
contactChannelCreation.CreationChannel.Should().Be(true);
contactChannelCreation.CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
contactChannelCreation.CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public void Candidate_MapsCorrectly()
candidate.Qualifications.First().DegreeSubject.Should().Be(request.DegreeSubject);
candidate.Qualifications.First().TypeId.Should().Be(request.DegreeTypeId);

candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelActivityId.Should().Be(request.CreationChannelActivityId);
candidate.ContactChannelCreations.First().CreationChannelSourceId.Should().Be(request.CreationChannelSourceId);
candidate.ContactChannelCreations.First().CreationChannelServiceId.Should().Be(request.CreationChannelServiceId);
candidate.ContactChannelCreations.First().CreationChannelActivityId.Should().Be(request.CreationChannelActivityId);

candidate.HasTeacherTrainingAdviserSubscription.Should().BeTrue();
}
Expand Down Expand Up @@ -301,9 +301,9 @@ public void Candidate_ContactChannelCreationWhenCandidateIdIsNull()

request.Candidate.ChannelId.Should().BeNull();
request.Candidate.ChangedPropertyNames.Should().Contain("ContactChannelCreations");
request.Candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelSourceId.Should().Be(222750000);
request.Candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelServiceId.Should().Be(222750001);
request.Candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelActivityId.Should().Be(222750002);
request.Candidate.ContactChannelCreations.First().CreationChannelSourceId.Should().Be(222750000);
request.Candidate.ContactChannelCreations.First().CreationChannelServiceId.Should().Be(222750001);
request.Candidate.ContactChannelCreations.First().CreationChannelActivityId.Should().Be(222750002);
}

[Fact]
Expand All @@ -320,9 +320,9 @@ public void Candidate_ContactChannelCreationWhenCandidateIdIsNotNull()
request.Candidate.ChannelId.Should().BeNull();
request.Candidate.ChangedPropertyNames.Should().NotContain("ChannelId");
request.Candidate.ChangedPropertyNames.Should().Contain("ContactChannelCreations");
request.Candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelSourceId.Should().Be(222750000);
request.Candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelServiceId.Should().Be(222750001);
request.Candidate.ContactChannelCreations.GetContactChannelCreations().First().CreationChannelActivityId.Should().Be(222750002);
request.Candidate.ContactChannelCreations.First().CreationChannelSourceId.Should().Be(222750000);
request.Candidate.ContactChannelCreations.First().CreationChannelServiceId.Should().Be(222750001);
request.Candidate.ContactChannelCreations.First().CreationChannelActivityId.Should().Be(222750002);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion GetIntoTeachingApiTests/Services/CandidateUpserterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void Upsert_WithContactChannelCreation_SavesContactChannelCreations()
CreationChannelSourceId = 222750002,
};

_candidate.ContactChannelCreations.AddContactChannelCreation(contactChannelCreation);
_candidate.ContactChannelCreations.Add(contactChannelCreation);

_upserter.Upsert(_candidate);

Expand Down

0 comments on commit 2ae66ef

Please sign in to comment.