public static void MapTo(this VerifiedOrganisation organisation, OrganisationalUnitEntity entity) { entity.parentId = organisation.ParentId; entity.accountManagerId = organisation.AccountManagerId; entity.verifiedById = organisation.VerifiedById; ((IHaveContactDetails)organisation).MapTo(entity); }
public void TestVerifiedSameNameDifferentParents() { // Should be possible to create verified organisations with the same name but different parents. var adminId = Guid.NewGuid(); var parent1 = new VerifiedOrganisation { Name = "Parent1", AccountManagerId = adminId, VerifiedById = adminId }; _organisationsCommand.CreateOrganisation(parent1); var parent2 = new VerifiedOrganisation { Name = "Parent2", AccountManagerId = adminId, VerifiedById = adminId }; _organisationsCommand.CreateOrganisation(parent2); var verified1 = new VerifiedOrganisation { Name = VerifiedName, AccountManagerId = adminId, VerifiedById = adminId }; verified1.SetParent(parent1); _organisationsCommand.CreateOrganisation(verified1); var verified2 = new VerifiedOrganisation { Name = VerifiedName, AccountManagerId = adminId, VerifiedById = adminId }; verified2.SetParent(parent2); _organisationsCommand.CreateOrganisation(verified2); Assert.AreNotEqual(Guid.Empty, verified1.Id); Assert.AreNotEqual(Guid.Empty, verified2.Id); Assert.AreNotEqual(verified1.Id, verified2.Id); }
public void TestUniqueVerifiedParent() { // Should not be possible to create verified organisations with the same name and same parent. var adminId = Guid.NewGuid(); var parent = new VerifiedOrganisation { Name = "Parent", AccountManagerId = adminId, VerifiedById = adminId }; _organisationsCommand.CreateOrganisation(parent); var verified1 = new VerifiedOrganisation { Name = VerifiedName, AccountManagerId = adminId, VerifiedById = adminId }; verified1.SetParent(parent); _organisationsCommand.CreateOrganisation(verified1); var verified2 = new VerifiedOrganisation { Name = VerifiedName, AccountManagerId = adminId, VerifiedById = adminId }; verified2.SetParent(parent); try { _organisationsCommand.CreateOrganisation(verified2); Assert.Fail("Expected an exception"); } catch (ValidationErrorsException ex) { Assert.AreEqual(1, ex.Errors.Count); Assert.IsInstanceOfType(ex.Errors[0], typeof(DuplicateValidationError)); } }
public static OrganisationalUnitEntity Map(this VerifiedOrganisation organisation) { var entity = new OrganisationalUnitEntity(); organisation.MapTo(entity); return(entity); }
private static void MapTo(this OrganisationEntity entity, VerifiedOrganisation organisation, string parentFullName) { organisation.AccountManagerId = entity.OrganisationalUnitEntity.accountManagerId; organisation.VerifiedById = entity.OrganisationalUnitEntity.verifiedById; organisation.ContactDetails = entity.OrganisationalUnitEntity.Map(); organisation.SetParent(entity.OrganisationalUnitEntity.parentId, parentFullName); }
private void TestCompanyName(bool hideCompany, string company) { var organisation = new VerifiedOrganisation { Id = OrganisationId, Name = company, }; _organisationsCommand.CreateOrganisation(organisation); var employer = _employerAccountsCommand.CreateTestEmployer(0, organisation); var jobAd = PostJobAd( employer, j => { j.Visibility.HideContactDetails = true; j.Visibility.HideCompany = hideCompany; j.Description.CompanyName = company; }); Get(GetJobUrl(jobAd.Id)); // Whether hidden or not the company name does not appear in this page. AssertPageContains(jobAd.Title); AssertPageDoesNotContain(company); }
public void TestNameErrors() { var administrator = _administratorAccountsCommand.CreateTestAdministrator(1); LogIn(administrator); var url = GetNewOrganisationUrl(); Get(url); // No name. _createButton.Click(); AssertErrorMessage("The name is required."); // Bad name. _nameTextBox.Text = "%$^&$#(^"; _createButton.Click(); AssertErrorMessage("The name must be between 1 and 100 characters in length and not have any invalid characters."); // Hierarchy name. var parent = new VerifiedOrganisation { Name = "Parent" }; var child = new VerifiedOrganisation { Name = "Child" }; child.SetParent(parent); _nameTextBox.Text = child.FullName; _createButton.Click(); AssertErrorMessage("The name must be between 1 and 100 characters in length and not have any invalid characters."); }
protected override Employer CreateEmployer() { var administratorId = Guid.NewGuid(); _parentOrganisation = _organisationsCommand.CreateTestVerifiedOrganisation(0, null, administratorId); var organisation = _organisationsCommand.CreateTestVerifiedOrganisation(1, _parentOrganisation, administratorId); return(_employerAccountsCommand.CreateTestEmployer(0, organisation)); }
public void TestCompanyNameChanged() { const string verifiedCompanyName = "Verified Company"; var employer = CreateEmployer(0); LogIn(employer); Get(_settingsUrl); // Update the unverified company name Assert.IsFalse(_organisationNameTextBox.IsReadOnly); Assert.AreEqual(employer.Organisation.FullName, _organisationNameTextBox.Text); _organisationNameTextBox.Text = NewCompanyName; _saveButton.Click(); AssertUrlWithoutQuery(LoggedInEmployerHomeUrl); LogOut(); // Check that the update succeeded. var updatedEmployer = _employersQuery.GetEmployer(employer.Id); Assert.AreEqual(NewCompanyName, updatedEmployer.Organisation.FullName); // Make a verified company. var admin = _administratorsCommand.CreateTestAdministrator(0); var organisation = new VerifiedOrganisation { Name = verifiedCompanyName, VerifiedById = admin.Id, AccountManagerId = admin.Id }; _organisationsCommand.CreateOrganisation(organisation); employer.Organisation = organisation; _employerAccountsCommand.UpdateEmployer(employer); LogIn(employer); Get(_settingsUrl); // Try to change name again. Assert.AreEqual(verifiedCompanyName, _organisationNameTextBox.Text); Assert.IsTrue(_organisationNameTextBox.IsReadOnly); _organisationNameTextBox.Text = NewCompanyName; _saveButton.Click(); // Check that the update was NOT made. updatedEmployer = _employersQuery.GetEmployer(employer.Id); Assert.AreEqual(verifiedCompanyName, updatedEmployer.Organisation.FullName); // Assert page. AssertUrlWithoutQuery(LoggedInEmployerHomeUrl); Get(_settingsUrl); Assert.AreEqual(verifiedCompanyName, _organisationNameTextBox.Text); }
public void TestInitialize() { _admin = _administratorAccountsCommand.CreateTestAdministrator(1); _orgUnit = _organisationsCommand.CreateTestVerifiedOrganisation("Headhunters Inc.", null, _admin.Id, _admin.Id); _employer = _employerAccountsCommand.CreateTestEmployer("employer", _organisationsCommand.CreateTestOrganisation(0)); _employer.Organisation = _orgUnit; _employer.CreatedTime = DateTime.Now.AddYears(-1); // Must exist before the reporting period _employerAccountsCommand.UpdateEmployer(_employer); }
private void TestCreateContactDetails(ContactDetails contactDetails, bool expectContactDetails, string expectedFirstName, string expectedLastName, string expectedEmailAddress, string expectedSecondaryEmailAddresses, string expectedFaxNumber, string expectedPhoneNumber) { var organisation = new VerifiedOrganisation { Name = Name, ContactDetails = contactDetails, }; _organisationsCommand.CreateOrganisation(organisation); AssertContactDetails(organisation.Id, expectContactDetails, expectedFirstName, expectedLastName, expectedEmailAddress, expectedSecondaryEmailAddresses, expectedFaxNumber, expectedPhoneNumber); }
protected override Organisation CreateOrganisation() { var organisation = new VerifiedOrganisation { Id = OrganisationId, Name = OrganisationName, }; _organisationsCommand.CreateOrganisation(organisation); return(organisation); }
protected override Domain.Contacts.Employer CreateEmployer() { // The id corresponds to an organisation (Database Consultants Australia (VIC)) that has customized styling. var organisation = new VerifiedOrganisation { Id = OrganisationId, Name = OrganisationName, }; _organisationsCommand.CreateOrganisation(organisation); return(_employerAccountsCommand.CreateTestEmployer(0, organisation)); }
public static VerifiedOrganisation CreateTestVerifiedOrganisation(this IOrganisationsCommand organisationsCommand, string name, Organisation parentOrganisation, Guid accountManagerId, Guid verifiedById) { var organisation = new VerifiedOrganisation { Name = name, VerifiedById = verifiedById, AccountManagerId = accountManagerId, }; organisation.SetParent(parentOrganisation); organisationsCommand.CreateOrganisation(organisation); return(organisation); }
private void TestUpdateContactDetails(ContactDetails fromContactDetails, ContactDetails toContactDetails, bool expectContactDetails, string expectedFirstName, string expectedLastName, string expectedEmailAddress, string expectedSecondaryEmailAddresses, string expectedFaxNumber, string expectedPhoneNumber) { var organisation = new VerifiedOrganisation { Name = Name, ContactDetails = fromContactDetails, }; _organisationsCommand.CreateOrganisation(organisation); organisation = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(organisation.Id); organisation.ContactDetails = toContactDetails; _organisationsCommand.UpdateOrganisation(organisation); AssertContactDetails(organisation.Id, expectContactDetails, expectedFirstName, expectedLastName, expectedEmailAddress, expectedSecondaryEmailAddresses, expectedFaxNumber, expectedPhoneNumber); }
private Organisation CreateOrganisation(int index, bool isVerified, Guid administratorId) { if (isVerified) { var verifiedOrganisation = new VerifiedOrganisation { Name = string.Format(OrganisationName, index), VerifiedById = administratorId, AccountManagerId = administratorId }; _organisationsCommand.CreateOrganisation(verifiedOrganisation); return(verifiedOrganisation); } var organisation = new Organisation { Name = string.Format(OrganisationName, index) }; _organisationsCommand.CreateOrganisation(organisation); return(organisation); }
VerifiedOrganisation IOrganisationsCommand.VerifyOrganisation(Organisation organisation, Guid accountManagerId, Guid verifiedById) { // Copy properties. var verifiedOrganisation = new VerifiedOrganisation { Id = organisation.Id, Name = organisation.Name, Address = organisation.Address == null ? null : organisation.Address.Clone(), AffiliateId = organisation.AffiliateId, ContactDetails = null, AccountManagerId = accountManagerId, VerifiedById = verifiedById }; Update(verifiedOrganisation); return(verifiedOrganisation); }
public static Organisation Map(this OrganisationEntity entity, string parentFullName, ILocationQuery locationQuery) { if (entity.OrganisationalUnitEntity == null) { var organisation = new Organisation { Id = entity.id }; entity.MapTo(organisation, locationQuery); return(organisation); } var verifiedOrganisation = new VerifiedOrganisation { Id = entity.id }; entity.MapTo(verifiedOrganisation, locationQuery); entity.MapTo(verifiedOrganisation, parentFullName); return(verifiedOrganisation); }
protected Employer CreateEmployer() { var organisation = new VerifiedOrganisation { Id = OrganisationId, Name = OrganisationName, }; _organisationsCommand.CreateOrganisation(organisation); var employer = _employerAccountsCommand.CreateTestEmployer(1, organisation); _allocationsCommand.CreateAllocation(new Allocation { OwnerId = employer.Id, CreditId = _creditsQuery.GetCredit <JobAdCredit>().Id, InitialQuantity = null }); _allocationsCommand.CreateAllocation(new Allocation { OwnerId = employer.Id, CreditId = _creditsQuery.GetCredit <ApplicantCredit>().Id }); return(employer); }
private static void AssertVerifiedOrganisation(VerifiedOrganisation expected, VerifiedOrganisation organisation) { Assert.AreEqual(expected.AccountManagerId, organisation.AccountManagerId); Assert.AreEqual(expected.VerifiedById, organisation.VerifiedById); if (expected.ContactDetails == null) { Assert.IsNull(organisation.ContactDetails); } else { Assert.IsNotNull(organisation.ContactDetails); Assert.AreEqual(expected.ContactDetails.EmailAddress, organisation.ContactDetails.EmailAddress); Assert.AreEqual(expected.ContactDetails.FaxNumber, organisation.ContactDetails.FaxNumber); Assert.AreEqual(expected.ContactDetails.FirstName, organisation.ContactDetails.FirstName); Assert.AreEqual(expected.ContactDetails.LastName, organisation.ContactDetails.LastName); Assert.AreEqual(expected.ContactDetails.PhoneNumber, organisation.ContactDetails.PhoneNumber); Assert.AreEqual(expected.ContactDetails.SecondaryEmailAddresses, organisation.ContactDetails.SecondaryEmailAddresses); } }
private void TestContactDetails(bool hideContactDetails, bool hideCompany, string firstName, string lastName, string company, string phoneNumber, string expectedContactDetails) { var organisation = new VerifiedOrganisation { Id = OrganisationId, Name = company, }; _organisationsCommand.CreateOrganisation(organisation); var employer = _employerAccountsCommand.CreateTestEmployer(0, organisation); var jobAd = PostJobAd( employer, j => { j.Visibility.HideContactDetails = hideContactDetails; j.Visibility.HideCompany = hideCompany; j.ContactDetails = new ContactDetails { FirstName = firstName, LastName = lastName, CompanyName = company, PhoneNumber = phoneNumber }; }); // Get the job. Get(GetJobUrl(jobAd.Id)); Assert.AreEqual(expectedContactDetails, GetContactDetails()); // Make sure the details don't appear anywhere if hidden. if (hideContactDetails) { AssertPageDoesNotContain(firstName); AssertPageDoesNotContain(lastName); AssertPageDoesNotContain(company); AssertPageDoesNotContain(phoneNumber); } if (hideCompany) { AssertPageDoesNotContain(company); } }
public ActionResult New([Bind(Include = "ParentFullName")] string parentFullName, [Bind(Include = "Name")] string name, [Bind(Include = "Location")] string location, [Bind(Include = "AccountManagerId")] Guid accountManagerId, [Bind(Include = "FirstName,LastName,EmailAddress")] ContactDetails contactDetails, [Bind(Include = "CommunityId")] Guid?communityId) { // Can only create a verified organisation. contactDetails.ParseEmailAddresses(contactDetails.EmailAddress); var organisation = new VerifiedOrganisation { Name = name, Address = GetAddress(location), AccountManagerId = accountManagerId, VerifiedById = CurrentAdministrator.Id, ContactDetails = contactDetails, AffiliateId = communityId, }; try { organisation.SetParent(GetParentOrganisation(parentFullName)); // Create the organisation itself. _organisationsCommand.CreateOrganisation(organisation); return(RedirectToRouteWithConfirmation(OrganisationsRoutes.Edit, new { organisation.Id }, HttpUtility.HtmlEncode("The '" + organisation.FullName + "' organisation has been created."))); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } // Show the errors. var accountManagers = GetAccountManagers(organisation); return(View(new OrganisationModel { Organisation = organisation, AccountManagers = accountManagers, VerifiedByAccountManager = GetVerifiedByAccountManager(organisation, accountManagers), Communities = _communitiesQuery.GetCommunities(), })); }
public AccountManagerReportEmail(ICommunicationUser accountManager, Report report, VerifiedOrganisation organisation, DateTime startDate, DateTime endDate) : base(accountManager) { if (report == null) { throw new ArgumentNullException("report"); } if (organisation == null) { throw new ArgumentNullException("organisation"); } if (accountManager == null) { throw new ArgumentNullException("accountManager"); } _report = report; _organisation = organisation; _accountManager = accountManager; _startDate = startDate; _endDate = endDate; }
public void TestVerifyOrganisation() { var administrator = _administratorAccountsCommand.CreateTestAdministrator(1); var organisation = _organisationsCommand.CreateTestOrganisation(1); // Get the page. LogIn(administrator); var url = GetOrganisationUrl(organisation); Get(url); AssertUrl(url); AssertUnverifiedDetails(organisation); // Verify it. _verifyButton.Click(); // Check the page. AssertUrl(url); AssertVerifiedDetails(organisation, administrator, administrator); // Check what is saved. var verifiedOrganisation = new VerifiedOrganisation { Id = organisation.Id, Name = organisation.Name, AccountManagerId = administrator.Id, VerifiedById = administrator.Id }; AssertOrganisation(verifiedOrganisation, _organisationsQuery.GetOrganisation(organisation.Id)); }
public void TestUniqueVerifiedNoParent() { // Should not be possible to create verified organisations with the same name. var verified1 = new VerifiedOrganisation { Name = VerifiedName }; _organisationsCommand.CreateOrganisation(verified1); var verified2 = new VerifiedOrganisation { Name = VerifiedName }; try { _organisationsCommand.CreateOrganisation(verified2); Assert.Fail("Expected an exception"); } catch (ValidationErrorsException ex) { Assert.AreEqual(1, ex.Errors.Count); Assert.IsInstanceOfType(ex.Errors[0], typeof(DuplicateValidationError)); } }
private void EditPrimaryContact(ReadOnlyUrl url, string existingFirstName, string existingLastName, string existingEmailAddress, string newFirstName, string newLastName, string newEmailAddress, VerifiedOrganisation organisation) { Get(url); Assert.AreEqual(existingFirstName, _firstNameTextBox.Text); Assert.AreEqual(existingLastName, _lastNameTextBox.Text); Assert.AreEqual(existingEmailAddress, _emailAddressTextBox.Text); // Set all the fields. _firstNameTextBox.Text = newFirstName; _lastNameTextBox.Text = newLastName; _emailAddressTextBox.Text = newEmailAddress; _saveButton.Click(); Assert.AreEqual(newFirstName, _firstNameTextBox.Text); Assert.AreEqual(newLastName, _lastNameTextBox.Text); Assert.AreEqual(newEmailAddress, _emailAddressTextBox.Text); // Load the page again and check Get(url); Assert.AreEqual(newFirstName, _firstNameTextBox.Text); Assert.AreEqual(newLastName, _lastNameTextBox.Text); Assert.AreEqual(newEmailAddress, _emailAddressTextBox.Text); organisation.ContactDetails = string.IsNullOrEmpty(newFirstName) && string.IsNullOrEmpty(newLastName) && string.IsNullOrEmpty(newEmailAddress) ? null : GetContactDetails(newFirstName, newLastName, newEmailAddress); AssertOrganisation(organisation, _organisationsQuery.GetOrganisation(organisation.Id)); }
public void TestVerifiedFullNames() { var verifiedName = VerifiedName; var adminId = Guid.NewGuid(); var verified = new VerifiedOrganisation { Name = verifiedName, VerifiedById = adminId, AccountManagerId = adminId }; _organisationsCommand.CreateOrganisation(verified); Assert.AreEqual(verifiedName, verified.Name); Assert.AreEqual(verifiedName, verified.FullName); // Set up parent and child organisations. var parentName = "Parent Company"; var childName = "Child Company"; var parent = new VerifiedOrganisation { Name = parentName, VerifiedById = adminId, AccountManagerId = adminId }; _organisationsCommand.CreateOrganisation(parent); var child = new VerifiedOrganisation { Name = childName, VerifiedById = adminId, AccountManagerId = adminId }; _organisationsCommand.CreateOrganisation(child); // Parent => Verified => Child. verified.SetParent(parent); _organisationsCommand.UpdateOrganisation(verified); child.SetParent(verified); _organisationsCommand.UpdateOrganisation(child); // Test the full names. Assert.AreEqual(parentName, parent.Name); Assert.AreEqual(parentName, parent.FullName); Assert.AreEqual(verifiedName, verified.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName, verified.FullName); Assert.AreEqual(childName, child.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName + Organisation.FullNameSeparator + childName, child.FullName); // Re-read and make sure they still work. parent = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(parent.Id); verified = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(verified.Id); child = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(child.Id); Assert.AreEqual(parentName, parent.Name); Assert.AreEqual(parentName, parent.FullName); Assert.AreEqual(verifiedName, verified.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName, verified.FullName); Assert.AreEqual(childName, child.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName + Organisation.FullNameSeparator + childName, child.FullName); // Change some names childName = "Child Changed"; child.Name = childName; Assert.AreEqual(childName, child.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName + Organisation.FullNameSeparator + childName, child.FullName); verifiedName = "Verified Changed"; verified.Name = verifiedName; Assert.AreEqual(verifiedName, verified.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName, verified.FullName); parentName = "Parent Changed"; parent.Name = parentName; Assert.AreEqual(parentName, parent.Name); Assert.AreEqual(parentName, parent.FullName); // Update. _organisationsCommand.UpdateOrganisation(parent); _organisationsCommand.UpdateOrganisation(verified); _organisationsCommand.UpdateOrganisation(child); parent = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(parent.Id); verified = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(verified.Id); child = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(child.Id); Assert.AreEqual(parentName, parent.Name); Assert.AreEqual(parentName, parent.FullName); Assert.AreEqual(verifiedName, verified.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName, verified.FullName); Assert.AreEqual(childName, child.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName + Organisation.FullNameSeparator + childName, child.FullName); // Change the parent to another company child.SetParent(parent); Assert.AreEqual(childName, child.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + childName, child.FullName); _organisationsCommand.UpdateOrganisation(child); parent = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(parent.Id); verified = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(verified.Id); child = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(child.Id); Assert.AreEqual(parentName, parent.Name); Assert.AreEqual(parentName, parent.FullName); Assert.AreEqual(verifiedName, verified.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + verifiedName, verified.FullName); Assert.AreEqual(childName, child.Name); Assert.AreEqual(parentName + Organisation.FullNameSeparator + childName, child.FullName); }
private IEnumerable <TemplateEmail> RunReport(EmployerReport report, VerifiedOrganisation organisation, DateTime startDate, DateTime endDate, IAdministrator accountManager) { // First work out who we need to send it to var contactDetails = report.SendToClient ? _organisationsQuery.GetEffectiveContactDetails(organisation.Id) : null; var accountManagerEmail = report.SendToAccountManager && accountManager.IsEnabled ? new AccountManagerReportEmail((ICommunicationUser)accountManager, report, organisation, startDate, endDate) : null; if (contactDetails == null && accountManagerEmail == null) { return(new TemplateEmail[0]); // No-one to send the report to. } // Run the report and attach it to the email(s). string fileName = GetFilename(report, organisation, ".pdf"); var pdfStream = new MemoryStream(); var sb = new StringBuilder(); var outcome = _executeEmployerReportsCommand.RunReport(report, true, organisation, accountManager, new DateRange(startDate, endDate), null, pdfStream, sb); if (outcome == ReportRunOutcome.InvalidParameters) { return(new TemplateEmail[0]); } if (accountManagerEmail != null) { switch (outcome) { case ReportRunOutcome.TextResultOnly: accountManagerEmail.AddCustomHtml(GetResultsHtml(report, organisation, sb.ToString())); break; case ReportRunOutcome.NoResults: accountManagerEmail.AddNoActivityReport(report); break; } } var allEmails = new List <TemplateEmail>(); if (accountManagerEmail != null) { allEmails.Add(accountManagerEmail); } if (contactDetails != null && (report.ReportAsFile || sb.Length != 0)) { if (!string.IsNullOrEmpty(contactDetails.EmailAddress)) { allEmails.Add(CreateEmail( new Employer { EmailAddress = new EmailAddress { Address = contactDetails.EmailAddress }, FirstName = contactDetails.FirstName, LastName = contactDetails.LastName, IsEnabled = true }, (ICommunicationUser)accountManager, report, organisation, startDate, endDate, outcome, sb.ToString(), _memberCount)); } if (!string.IsNullOrEmpty(contactDetails.SecondaryEmailAddresses)) { var secondaryEmailAddresses = TextUtil.SplitEmailAddresses(contactDetails.SecondaryEmailAddresses); if (secondaryEmailAddresses != null) { foreach (var secondaryEmailAddress in secondaryEmailAddresses) { allEmails.Add(CreateEmail( new Employer { EmailAddress = new EmailAddress { Address = secondaryEmailAddress }, IsEnabled = true }, (ICommunicationUser)accountManager, report, organisation, startDate, endDate, outcome, sb.ToString(), _memberCount)); } } } } if (outcome == ReportRunOutcome.FileResult || report.ReportFileEvenIfNoResults) { foreach (var email in allEmails) { if (email != null) { // The same Stream can't be used for multiple attachments, so clone it. var attachmentStream = new MemoryStream(pdfStream.ToArray()); email.AddAttachments(new[] { new ContentAttachment(attachmentStream, fileName, MediaType.Pdf) }); } } } return(allEmails); }