public void TestResultsNoPreviousEmployer()
        {
            // Create an employer and search.

            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // Remove the employer.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);
            var resume    = _candidateResumesCommand.AddTestResume(candidate);

            resume.Jobs[1].Company = "";
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
        public void TestResultsNotNew()
        {
            // Create an employer and search.

            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // Set created time back beyond the fresh days interval.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);
            member.CreatedTime -= SearchResultFreshDays.Add(SearchResultFreshDays);
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
        public void TestResultsNoPreviousJob()
        {
            // Create an employer and search.

            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // Remove all jobs except the first, which is the current job.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);
            var resume    = _candidateResumesCommand.AddTestResume(candidate);

            while (resume.Jobs.Count > 1)
            {
                resume.Jobs.RemoveAt(1);
            }
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
        public void TestResultsNoCurrentJob()
        {
            // Create an employer and search.

            var employer = CreateEmployer(0, false);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // No current job.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);
            var resume    = _candidateResumesCommand.AddTestResume(candidate);

            resume.Jobs = null;
            _candidateResumesCommand.UpdateResume(candidate, resume);
            var results = new MemberSearchResults {
                MemberIds = new [] { member.Id }, TotalMatches = 1
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
        public void TestResultsNoLocation()
        {
            // Create an employer and search.

            var employer = CreateEmployer(0, false);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // No location.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);
            _locationQuery.ResolvePostalSuburb(member.Address.Location, _australia, "");
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            SendAlertEmail(employer, search, results);
        }
        private void AssertSubject(int index, MemberSearchResults results, string jobTitle, string keywords, LocationReference location, Salary salary, JobTypes jobTypes, int maximumLength)
        {
            // Create an employer and search.

            var employer = CreateEmployer(index, false);
            var criteria = new MemberSearchCriteria
            {
                JobTitle = jobTitle,
                Location = location,
                Salary   = salary,
                JobTypes = jobTypes
            };

            criteria.SetKeywords(keywords);
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // Send an email.

            SendAlertEmail(employer, search, results);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertSubject(GetSubject(search.Criteria, maximumLength));
        }
        private TemplateEmail SendAlertEmail(Employer employer, MemberSearch search, MemberSearchResults results)
        {
            var email = new ResumeSearchAlertEmail(employer, search.Criteria, null, results, _employerMemberViewsQuery.GetEmployerMemberViews(employer, results.MemberIds), search.Id);

            _emailsCommand.TrySend(email);
            return(email);
        }
        public void TestCriteriaJobTypes()
        {
            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle, JobTypes = JobTypes.FullTime | JobTypes.Contract
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // No location.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
        public void TestCriteriaCandidateStatus()
        {
            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle, CandidateStatusFlags = CandidateStatusFlags.ActivelyLooking | CandidateStatusFlags.AvailableNow
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // No location.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
示例#10
0
        private MemberSearchResults GetSearchResults(BrowseResult result, int skip, int take)
        {
            // TotalMatches

            var searchResults = new MemberSearchResults {
                TotalMatches = result.getNumHits()
            };

            // MemberIds

            var hits = result.getHits();

            searchResults.MemberIds = hits
                                      .Skip(skip)
                                      .Take(take)
                                      .Select(hit => new Guid(_browser.doc(hit.getDocid()).get(SearchFieldName.Id)))
                                      .ToArray();

            // Facets

            var facetMap = result.getFacetMap();

            if (facetMap != null)
            {
                searchResults.CandidateStatusHits = GetFieldHits(facetMap, FieldName.CandidateStatus, v => v.DecodeToCandidateStatus());
                searchResults.IndustryHits        = GetFieldHits(facetMap, FieldName.Industries, v => new Guid(v));
                searchResults.DesiredJobTypeHits  = GetFieldHits(facetMap, FieldName.DesiredJobTypes, v => JobTypesFieldHandler.Decode(v));
            }

            return(searchResults);
        }
        public void TestDesiredSalary()
        {
            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // No location.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            candidate.DesiredSalary = new Salary {
                LowerBound = 20000, UpperBound = 40000, Currency = Currency.AUD, Rate = SalaryRate.Year
            };
            _candidateResumesCommand.AddTestResume(candidate);
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
        public void TestCriteriaEthnicStatus()
        {
            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle, EthnicStatus = EthnicStatus.Aboriginal | EthnicStatus.TorresIslander
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // No location.

            var member    = CreateMember();
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
示例#13
0
        internal MemberSearchResults SearchForMembers(PageHandle pageHandle)
        {
            ReAuthenticateIfRequired();
            MemberSearchResults results = fMemberService.GetSearchResults(ref fMemberAuthentication, pageHandle);

            UpdateAuthenticationTokens(fMemberAuthentication.AuthenticationToken);

            return(results);
        }
示例#14
0
        public void TestResumeSearchAlertEmail()
        {
            // Create an employer and search.

            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            var member    = _memberAccountsCommand.CreateTestMember(0);
            var candidate = _candidatesQuery.GetCandidate(member.Id);

            _candidateResumesCommand.AddTestResume(candidate);
            var results = new MemberSearchResults {
                MemberIds = new[] { member.Id }, TotalMatches = 1
            };

            // Send.

            _emailsCommand.TrySend(new ResumeSearchAlertEmail(employer, search.Criteria, null, results, _employerMemberViewsQuery.GetEmployerMemberViews(employer, results.MemberIds), search.Id));

            // Check email.

            var email = _emailServer.AssertEmailSent();
            var links = email.GetHtmlView().GetLinks();

            Assert.AreEqual(3, links.Count);

            var definition = typeof(ResumeSearchAlertEmail).Name;

            // Check the tracking pixel.

            var link = email.GetHtmlView().GetImageLinks().Last();

            AssertTrackingLink(link);

            // Not logged in.

            var url = _candidatesUrl.AsNonReadOnly();

            url.QueryString.Add("candidateId", member.Id.ToString());
            AssertLink(definition, employer, url, GetCandidateUrl(member), links[0]);
            AssertLink(definition, employer, _savedResumeSearchAlertsUrl, links[1]);
            AssertLink(definition, _contactUsUrl, links[2]);

            // Logged in.

            LogIn(employer);

            AssertLink(definition, GetCandidateUrl(member), links[0]);
            AssertLink(definition, _savedResumeSearchAlertsUrl, links[1]);
        }
        private string GetResults(TemplateEmail templateEmail, IEmployer employer, MemberSearchResults results, bool useExtraReturn, ref int resultsWritten)
        {
            var sb      = new StringBuilder();
            var matches = results.TotalMatches;

            if (matches > 0)
            {
                AppendResults(sb, templateEmail, employer, results, 0, Math.Min(matches, MaximumResults), useExtraReturn, ref resultsWritten);
            }
            return(sb.ToString());
        }
        public List <MemberSearchResults> loadMemberSearch(string APIKey, string city, string state, string gender, string commitment, string haveKids, string wantKids, string occupation)
        {
            if (APIKey == this.APIKey)
            {
                List <MemberSearchResults> profiles = new List <MemberSearchResults>();
                MemberSearchResults        profile;


                DBConnect  objDB  = new DBConnect();
                SqlCommand objCmd = new SqlCommand();
                objCmd.CommandType = CommandType.StoredProcedure;
                objCmd.CommandText = "TP_MemberSearch";

                objCmd.Parameters.AddWithValue("@city", city);
                objCmd.Parameters.AddWithValue("@state", state);
                objCmd.Parameters.AddWithValue("@gender", gender);
                objCmd.Parameters.AddWithValue("@commitment", commitment);
                objCmd.Parameters.AddWithValue("@haveKids", haveKids);
                objCmd.Parameters.AddWithValue("@wantKids", wantKids);
                objCmd.Parameters.AddWithValue("@occupation", occupation);

                DataSet searchResultsDS = objDB.GetDataSetUsingCmdObj(objCmd);

                if (searchResultsDS.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow result in searchResultsDS.Tables[0].Rows)
                    {
                        profile            = new MemberSearchResults();
                        profile.Title      = result["Title"].ToString();
                        profile.Username   = result["Username"].ToString();
                        profile.FirstName  = result["FirstName"].ToString();
                        profile.LastName   = result["LastName"].ToString();
                        profile.City       = result["HomeCity"].ToString();
                        profile.State      = result["HomeState"].ToString();
                        profile.Gender     = result["Gender"].ToString();
                        profile.Commitment = result["Commitment"].ToString();
                        profile.HaveKids   = result["haveKids"].ToString();
                        profile.WantKids   = result["wantKids"].ToString();
                        profile.Occupation = result["Occupation"].ToString();
                        profiles.Add(profile);
                    }
                    return(profiles);
                }
                else
                {
                    return(profiles);
                }
            }
            else
            {
                return(new List <MemberSearchResults>());
            }
        }
示例#17
0
        public ResumeSearchAlertEmail(ICommunicationUser to, MemberSearchCriteria criteria, IList <Industry> criteriaIndustries, MemberSearchResults results, EmployerMemberViews views, Guid savedSearchId)
            : base(to)
        {
            if (results == null)
            {
                throw new ArgumentNullException("results");
            }

            _results       = results;
            _views         = views;
            _criteriaText  = GetCriteriaText(criteria, criteriaIndustries);
            _savedSearchId = savedSearchId;
        }
示例#18
0
        public static string GetItemsFoundHtml(this MemberSearchResults results)
        {
            var sb      = new StringBuilder();
            var matches = results.TotalMatches;

            if (matches == 1)
            {
                sb.Append("<b>1 candidate</b> was found");
            }
            else
            {
                sb.Append("<b>").Append(matches).Append(" candidates</b> were found");
            }

            return(sb.ToString());
        }
示例#19
0
        private static ResumeSearchResultSetEntity Map(this MemberSearchResults results, int maxCount)
        {
            var entity = new ResumeSearchResultSetEntity
            {
                id    = results.Id,
                count = results.TotalMatches,
                ResumeSearchResultEntities = new EntitySet <ResumeSearchResultEntity>()
            };

            entity.ResumeSearchResultEntities.AddRange(
                from r in Enumerable.Range(1, Math.Min(results.MemberIds.Count, maxCount))
                select new ResumeSearchResultEntity
            {
                rank     = (short)r,
                resumeId = results.MemberIds[r - 1]
            });

            return(entity);
        }
示例#20
0
        public static string GetCaptionDisplayHtml(this MemberSearchResults results, MemberSearchCriteria criteria, int startIndex, int numResults)
        {
            var matches = results.TotalMatches;
            var sb      = new StringBuilder();

            if (matches == 0)
            {
                return("No results found");
            }

            sb.AppendFormat("Results {0}-{1}<small> of {2}</small>", (startIndex + 1), Math.Min(startIndex + numResults, matches), matches);

            if (criteria != null)
            {
                sb.Append(" matching " + criteria.GetDisplayHtml());
            }

            return(sb.ToString());
        }
        public void TestUpdatedNewGrouping()
        {
            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria {
                JobTitle = JobTitle, CandidateStatusFlags = CandidateStatusFlags.ActivelyLooking | CandidateStatusFlags.AvailableNow
            };
            var search = new MemberSearch {
                OwnerId = employer.Id, Criteria = criteria
            };

            // No location.

            var newMember1 = CreateMember(0);
            var candidate  = _candidatesCommand.GetCandidate(newMember1.Id);

            _candidateResumesCommand.AddTestResume(candidate);

            var updatedMember1 = CreateMember(1, DateTime.Now.AddDays(-100));

            var newMember2 = CreateMember(2);

            var updatedMember2 = CreateMember(3, DateTime.Now.AddDays(-100));

            candidate = _candidatesCommand.GetCandidate(updatedMember2.Id);
            _candidateResumesCommand.AddTestResume(candidate);

            //ordering is important - should be new, new, updated, updated
            var results = new MemberSearchResults {
                MemberIds = new[] { newMember1.Id, newMember2.Id, updatedMember1.Id, updatedMember2.Id }, TotalMatches = 4
            };

            // Send.

            var email = SendAlertEmail(employer, search, results);

            // Check.

            AssertMail(email, employer, search, results, 2, 2, true);
        }
示例#22
0
 protected abstract void Alert(Employer employer, MemberSearch search, MemberSearchAlert alert, MemberSearchResults results);
 protected override void Alert(Employer employer, MemberSearch search, MemberSearchAlert alert, MemberSearchResults results)
 {
     _pushNotificationsCommand.SendNotification(employer, results, alert.MemberSearchId, alert.Id);
 }
        protected override void Alert(Employer employer, MemberSearch search, MemberSearchAlert alert, MemberSearchResults results)
        {
            var industries = search.Criteria.IndustryIds == null ? null : (from i in search.Criteria.IndustryIds select _industriesQuery.GetIndustry(i)).ToList();

            _emailsCommand.TrySend(new ResumeSearchAlertEmail(employer, search.Criteria, industries, results, _employerMemberViewsQuery.GetEmployerMemberViews(employer, results.MemberIds), alert.MemberSearchId));
        }
示例#25
0
        public void SendNotification(Employer employer, MemberSearchResults results, Guid savedSearchId, Guid savedSearchAlertId)
        {
            const string method = "SendNotification";

            var devices     = _appleDevicesQuery.GetDevices(employer.Id);
            var savedSearch = _memberSearchAlertsQuery.GetMemberSearch(savedSearchId);

            if (devices == null || devices.Count == 0)
            {
                EventSource.Raise(Event.Error, method, "No devices registered for user with notifications turned on", Event.Arg("employer", employer.Id));
                return;
            }

            foreach (var device in devices)
            {
                if (!device.Active)
                {
                    continue;
                }

                if (results.MemberIds.Count == 0)
                {
                    continue;
                }

                //Exclude any ids that haven't already been viewed
                var unviewed = _memberSearchAlertsQuery.GetUnviewedCandidates(employer.Id, savedSearchAlertId);
                var potentationAlertableMemberIds = unviewed == null || unviewed.Count() == 0 ? results.MemberIds : results.MemberIds.Except(unviewed.Select(r => r.CandidateId));
                var alertableMemberIds            = new List <Guid>();

                //Exclude any ids that haven't been updated since last alert (possible where the alert was sent earlier today)
                foreach (var memberId in potentationAlertableMemberIds)
                {
                    var lastAlert = _memberSearchAlertsQuery.LastAlert(memberId, savedSearchAlertId);
                    if (lastAlert == null)
                    {
                        alertableMemberIds.Add(memberId);
                    }
                    else
                    {
                        //Need to determine if this is genuinely a new alert or just an update from earlier today
                        var member    = _membersQuery.GetMember(memberId);
                        var candidate = _candidatesQuery.GetCandidate(memberId);
                        var resume    = candidate == null ? null : candidate.ResumeId.HasValue ? null : _resumesQuery.GetResume(candidate.ResumeId.Value);

                        var lastUpdatedTime = new[]
                        {
                            member.LastUpdatedTime,
                            candidate == null ? DateTime.MinValue : candidate.LastUpdatedTime,
                            resume == null ? DateTime.MinValue : resume.LastUpdatedTime,
                        }.Max();

                        //if the member has updated since the last alert was sent then send a new one
                        if (lastUpdatedTime > lastAlert.CreatedTime)
                        {
                            alertableMemberIds.Add(memberId);
                        }
                    }
                }

                if (alertableMemberIds.Count() == 0)
                {
                    continue;
                }

                _memberSearchAlertsCommand.AddResults(employer.Id,
                                                      alertableMemberIds.Select(
                                                          r =>
                                                          new SavedResumeSearchAlertResult
                {
                    CandidateId = r,
                    SavedResumeSearchAlertId = savedSearchAlertId,
                    Viewed = false
                }).ToList());

                var alertNotification = new Notification(device.DeviceToken);
                alertNotification.Payload.Alert.ActionLocalizedKey = "View";
                alertNotification.Payload.Sound = "default";

                var badgeCount = _memberSearchAlertsQuery.GetBadgeCount(employer.Id);
                alertNotification.Payload.Badge = badgeCount;

                //Max payload size is 256 bytes; can't add memberIds
                //alertNotification.Payload.AddCustom("SavedSearchId", new[] {savedSearchId.ToString()});
                //alertNotification.Payload.AddCustom("MemberIds", alertableMemberIds.Select(a => a.ToString()).ToList());

                alertNotification.Payload.Alert.Body = alertableMemberIds.Count() == 1
                    ? string.Format("A new candidate has matched your \"{0}\" saved search", savedSearch.Name)
                    : string.Format("Your \"{0}\" saved search has new candidates", savedSearch.Name);

                if (EventSource.IsEnabled(Event.Trace))
                {
                    EventSource.Raise(Event.Trace, method, "Sending push notification",
                                      Event.Arg("employerId", employer.Id),
                                      Event.Arg("result count", alertableMemberIds.Count()),
                                      Event.Arg("saved search", savedSearchId),
                                      Event.Arg("saved searchname ", savedSearch.Name),
                                      Event.Arg("badge count", badgeCount),
                                      Event.Arg("deviceToken", device.DeviceToken),
                                      Event.Arg("alert payload", alertNotification.Payload.ToJson()));
                }

                //Queue the notification to be sent
                if (!_service.QueueNotification(alertNotification))
                {
                    EventSource.Raise(Event.Error, method, "Unable to queue notification", Event.Arg("deviceToken", device.DeviceToken));
                }
            }
        }
        private string GetContent(TemplateEmail templateEmail, IEmployer employer, MemberSearch search, MemberSearchResults results, int newCount, int updatedCount, bool useExtraReturn, out int written)
        {
            written = 0;

            var sb = new StringBuilder();

            sb.AppendLine("<p>");
            sb.AppendLine();
            sb.AppendLine();
            sb.Append("  <strong>" + results.TotalMatches + " candidate");

            if (results.TotalMatches != 1)
            {
                sb.Append("s");
                sb.AppendFormat(" ({0} new and {1} updated)", newCount, updatedCount);
            }

            sb.Append("</strong>");
            sb.Append(results.TotalMatches != 1 ? " were" : " was");
            sb.Append(" found");

            var criteriaText = GetCriteriaText(search.Criteria);

            if (string.IsNullOrEmpty(criteriaText))
            {
                sb.AppendLine();
            }
            else
            {
                sb.AppendLine(" for: " + criteriaText);
            }
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine("</p>");
            sb.AppendLine();

            // Results.

            var header = GetHeader(results);

            if (!string.IsNullOrEmpty(header))
            {
                sb.AppendLine("<p>");
                sb.AppendLine("  " + header);
                sb.AppendLine("</p>");
                sb.AppendLine("<p>");
                sb.Append(GetResults(templateEmail, employer, results, useExtraReturn, ref written));
                sb.AppendLine("</p>");
                sb.AppendLine();
            }

            var tinyUrl = GetTinyUrl(templateEmail, true, "~/employers/login", "returnUrl", new ReadOnlyApplicationUrl("~/ui/registered/employers/SavedResumeSearchAlerts.aspx").PathAndQuery);

            sb.AppendLine("<p>");
            sb.AppendLine("  Edit your daily candidate alerts");
            sb.AppendLine("  <a href=\"" + tinyUrl + "\">here.</a>");
            sb.AppendLine("</p>");
            sb.AppendLine("<!-- Saved resume search " + search.Id.ToString("B") + " -->");
            return(sb.ToString());
        }
        private void AssertMail(TemplateEmail templateEmail, Employer employer, MemberSearch search, MemberSearchResults results, int newCount, int updatedCount, bool useExtraReturn)
        {
            var email = _emailServer.AssertEmailSent();

            // Asert addresses.

            email.AssertAddresses(Return, Return, employer);
            AssertCompatibleAddresses(email);

            // Assert subject.

            email.AssertSubject(GetSubject(search.Criteria, MaximumSubjectLength));

            // Assert body.

            var longLines = new[]
            {
                "<strong>1 candidate</strong> was found for: Business Analyst, Developer, Melbourne VIC 3000, $100,000 to $200,000, Contract",
                "<strong>0 candidates (0 new and 0 updated)</strong> were found for: (no criteria)",
                "<strong>0 candidates (0 new and 0 updated)</strong> were found for: Business Analyst",
                "<strong>2 candidates (2 new and 0 updated)</strong> were found for: Business Analyst",
                "<strong>10 candidates (10 new and 0 updated)</strong> were found for: Business Analyst",
                "<strong>20 candidates (20 new and 0 updated)</strong> were found for: Business Analyst",
                "<strong>20 candidates (20 new and 10 updated)</strong> were found for: Business Analyst",
                "<strong>30 candidates (20 new and 10 updated)</strong> were found for: Business Analyst",
                "Temporary part-time libraries North-W..., Llanfairpwllgwyngyllgogerychwyrndrobw...",
                "Temporary part-time libraries North-W..., Ziffren, Brittenham, Branca, Fischer,...",
            };

            email.AssertHtmlViewChecks(null, true, longLines);
            var expected = Math.Min(results.TotalMatches, MaximumResults);
            int written;

            email.AssertHtmlView(GetBody(templateEmail, employer, GetContent(templateEmail, employer, search, results, newCount, updatedCount, useExtraReturn, out written)));

            Assert.AreEqual(expected, written);

            // Assert attachments.

            email.AssertNoAttachments();
        }
示例#28
0
        private void AddSearch(ICollection <NewsletterSearchModel> searches, string criteria, MemberSearchResults results, DateTimeRange lastMonth)
        {
            // Only add if there are in fact results.

            if (results.TotalMatches > 0)
            {
                searches.Add(new NewsletterSearchModel
                {
                    Criteria     = criteria,
                    Results      = results.TotalMatches,
                    NewLastMonth = _userAccountsQuery.GetCreatedAccountIds(results.MemberIds, lastMonth).Count
                });
            }
        }
        protected void AppendResults(StringBuilder sb, TemplateEmail templateEmail, IEmployer employer, MemberSearchResults results, int start, int count, bool useExtraReturn, ref int resultsWritten)
        {
            if (count > 0)
            {
                sb.AppendLine("  <div class=\"alert-container\">");
                sb.AppendLine();

                for (int index = start; index < start + count; index++)
                {
                    // Get the member for the result.

                    var view = _employerMemberViewsQuery.GetEmployerMemberView(employer, results.MemberIds[index]);
                    AppendResult(templateEmail, sb, view, index == start + 1 ? useExtraReturn : false, ref resultsWritten);
                }

                if (!useExtraReturn)
                {
                    sb.AppendLine();
                }
                sb.AppendLine("  </div>");
            }
        }