public void TestUpdateFirstName() { var employer = _employersCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(1)); AssertEmployer(employer, _employersQuery.GetEmployer(employer.Id)); employer.FirstName = "Changed"; _employersCommand.UpdateEmployer(employer); AssertEmployer(employer, _employersQuery.GetEmployer(employer.Id)); }
void IEmployerAccountsCommand.UpdateEmployer(Employer employer) { // Always make sure the phone number is a work phone number. if (employer.PhoneNumber != null) { employer.PhoneNumber.Type = PhoneNumberType.Work; } // Maintain the state of the email address. if (employer.EmailAddress != null) { var originalEmployer = _employersQuery.GetEmployer(employer.Id); employer.EmailAddress.IsVerified = originalEmployer.EmailAddress == null || employer.EmailAddress.Address != originalEmployer.EmailAddress.Address || originalEmployer.EmailAddress.IsVerified; } _employersCommand.UpdateEmployer(employer); }
public void TestOrganisationSharedNotes() { var member = _membersCommand.CreateTestMember(1); var noteCreator = _employersCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(1)); var organisation = noteCreator.Organisation; var noteReader = _employersCommand.CreateTestEmployer(2, organisation); // Create a private and a shared. var note1 = CreateNote(1, noteCreator, member.Id, false); NoteCreationDelay(); var note2 = CreateNote(2, noteCreator, member.Id, true); AssertNotes(noteCreator, member.Id, new[] { note2, note1 }, new CandidateNote[0]); AssertNotes(noteReader, member.Id, new[] { note2 }, new[] { note1 }); AssertHasNotes(noteCreator, member.Id); AssertHasNotes(noteReader, member.Id); // The creator leaves the company, so they cannot access their own shared notes. var otherOrganisation = new Organisation { Name = "OtherOrganisation" }; _organisationsCommand.CreateOrganisation(otherOrganisation); noteCreator.Organisation = otherOrganisation; _employersCommand.UpdateEmployer(noteCreator); AssertNotes(noteCreator, member.Id, new[] { note1 }, new[] { note2 }); AssertNotes(noteReader, member.Id, new[] { note2 }, new[] { note1 }); AssertHasNotes(noteCreator, member.Id); AssertHasNotes(noteReader, member.Id); // Create a private while not part of the company. var note3 = CreateNote(3, noteCreator, member.Id, false); AssertNotes(noteCreator, member.Id, new[] { note3, note1 }, new[] { note2 }); AssertNotes(noteReader, member.Id, new[] { note2 }, new[] { note3, note1 }); AssertHasNotes(noteCreator, member.Id); AssertHasNotes(noteReader, member.Id); // Join again so can see original notes. noteCreator.Organisation = organisation; _employersCommand.UpdateEmployer(noteCreator); AssertNotes(noteCreator, member.Id, new[] { note3, note2, note1 }, new CandidateNote[0]); AssertNotes(noteReader, member.Id, new[] { note2 }, new[] { note3, note1 }); AssertHasNotes(noteCreator, member.Id); AssertHasNotes(noteReader, member.Id); // Change the latest to shared, so now the second employer can see it. _candidateNotesCommand.ShareNote(noteCreator, note3); AssertNotes(noteCreator, member.Id, new[] { note3, note2, note1 }, new CandidateNote[0]); AssertNotes(noteReader, member.Id, new[] { note3, note2 }, new[] { note1 }); AssertHasNotes(noteCreator, member.Id); AssertHasNotes(noteReader, member.Id); // Make that one private once again. _candidateNotesCommand.UnshareNote(noteCreator, note3); AssertNotes(noteCreator, member.Id, new[] { note3, note2, note1 }, new CandidateNote[0]); AssertNotes(noteReader, member.Id, new[] { note2 }, new[] { note3, note1 }); AssertHasNotes(noteCreator, member.Id); AssertHasNotes(noteReader, member.Id); }