private void AssertSavedLogins(IOrganisation organisation, ICollection <Employer> expectedEmployers) { var recruiters = _recruitersQuery.GetRecruiters(organisation.Id); Assert.AreEqual(expectedEmployers.Count, recruiters.Count); foreach (var expectedEmployer in expectedEmployers) { var id = _loginCredentialsQuery.GetUserId(expectedEmployer.GetLoginId()); var employer = _employersQuery.GetEmployer(id.Value); Assert.IsNotNull(employer); // Check one of the recrutiers for the organisation. Assert.AreEqual(true, (from r in recruiters where r == employer.Id select r).Any()); Assert.AreEqual(expectedEmployer.EmailAddress, employer.EmailAddress); Assert.AreEqual(expectedEmployer.FirstName, employer.FirstName); Assert.AreEqual(expectedEmployer.LastName, employer.LastName); Assert.AreEqual(expectedEmployer.PhoneNumber, employer.PhoneNumber); Assert.AreEqual(expectedEmployer.JobTitle, employer.JobTitle); Assert.AreEqual(expectedEmployer.SubRole, employer.SubRole); Assert.AreEqual(1, employer.Industries.Count); Assert.AreEqual(expectedEmployer.Industries[0].Id, employer.Industries[0].Id); } }
public ActionResult Newsletter(CommunicationsContext context) { var employer = _employersQuery.GetEmployer(context.UserId); if (employer == null) { return(HttpNotFound()); } // Other enabled employers in the same organisation. var organisationHierarchy = _organisationsQuery.GetOrganisationHierarchy(employer.Organisation.Id); var employerIds = _recruitersQuery.GetRecruiters(organisationHierarchy); employerIds = _userAccountsQuery.GetEnabledAccountIds(employerIds); var lastLastLastMonth = new MonthRange(DateTime.Now.AddMonths(-3)); var lastLastMonth = new MonthRange(DateTime.Now.AddMonths(-2)); var lastMonth = new MonthRange(DateTime.Now.AddMonths(-1)); var model = CreateModel <NewsletterModel>(context); model.LoginId = _loginCredentialsQuery.GetLoginId(employer.Id); model.Employer = employer; model.SampleSearches = GetCachedSampleSearches(); model.PreviousSearches = GetPreviousSearches(employer, employerIds, lastMonth); model.Ranks = GetRanks(employer.Id, employerIds, lastLastLastMonth, lastLastMonth, lastMonth); return(View(model)); }
private Tuple <IList <Employer>, Administrator> GetRecipients(Guid ownerId) { // Look for employer. var employer = _employersQuery.GetEmployer(ownerId); if (employer != null) { return(new Tuple <IList <Employer>, Administrator>(new[] { employer }, null)); } // Look for organisation. var organisation = _organisationsQuery.GetOrganisation(ownerId); if (organisation == null) { return(new Tuple <IList <Employer>, Administrator>(new List <Employer>(), null)); } // If unverified send to all employers. if (!organisation.IsVerified) { return(new Tuple <IList <Employer>, Administrator>(_employersQuery.GetEmployers(_recruitersQuery.GetRecruiters(ownerId)), null)); } // Look for contact. var verifiedOrganisation = (VerifiedOrganisation)organisation; if (verifiedOrganisation.ContactDetails != null && verifiedOrganisation.ContactDetails.EmailAddress != null && verifiedOrganisation.ContactDetails.FirstName != null && verifiedOrganisation.ContactDetails.LastName != null) { return(new Tuple <IList <Employer>, Administrator>(new List <Employer> { new Employer { Id = organisation.Id, IsEnabled = true, EmailAddress = new EmailAddress { Address = verifiedOrganisation.ContactDetails.EmailAddress, IsVerified = true }, FirstName = verifiedOrganisation.ContactDetails.FirstName, LastName = verifiedOrganisation.ContactDetails.LastName, } }, _administratorsQuery.GetAdministrator(verifiedOrganisation.AccountManagerId))); } // Send to all employers. return(new Tuple <IList <Employer>, Administrator>(_employersQuery.GetEmployers(_recruitersQuery.GetRecruiters(ownerId)), _administratorsQuery.GetAdministrator(verifiedOrganisation.AccountManagerId))); }
private IEnumerable <Guid> GetPosterIds() { return(_report.IncludeChildOrganisations ? _recruitersQuery.GetRecruiters(_organisationsQuery.GetSubOrganisationHierarchy(_organisation.Id)) : _recruitersQuery.GetRecruiters(_organisation.Id)); }