Ejemplo n.º 1
0
        public void TestSaveSearch()
        {
            CreateMember();
            var employer = CreateEmployer();

            LogIn(employer);

            // Search.

            Get(new ReadOnlyApplicationUrl("~/search/candidates"));
            _keywordsTextBox.Text = JobTitle;
            _searchButton.Click();

            // Save.

            const string name = "MySearch";

            EmulateSaveSearchPopup(name, false);
            AssertSearch(employer.Id, false);

            // Search.

            GetPage <SavedResumeSearches>();
            _lbExecute.Click();

            var savedSearchId = _memberSearchesQuery.GetMemberSearches(employer.Id)[0].Id;

            AssertUrl(new ReadOnlyApplicationUrl(true, "~/search/candidates/saved/" + savedSearchId));
        }
Ejemplo n.º 2
0
        private IList <NewsletterSearchModel> GetPreviousSearches(IEmployer employer, IEnumerable <Guid> employerIds, DateTimeRange lastMonth)
        {
            var searches = new List <NewsletterSearchModel>();

            // Start with saved searches.

            var memberSearches = _memberSearchesQuery.GetMemberSearches(new[] { employer.Id }, new Range(0, MaxPreviousSearches));

            AddPreviousSearches(searches, employer, from s in memberSearches select s.Criteria, lastMonth);

            // Previous searches.

            if (searches.Count < MaxPreviousSearches)
            {
                var previousSearches = _memberSearchesQuery.GetMemberSearchExecutions(new[] { employer.Id }, new Range(0, MaxPreviousSearches - searches.Count));
                AddPreviousSearches(searches, employer, from s in previousSearches select s.Criteria, lastMonth);
            }

            // Organisation searches.

            if (searches.Count < MaxPreviousSearches)
            {
                // Do not repeat the employer's searches.

                employerIds = employerIds.Except(new[] { employer.Id }).ToList();

                // Saved searches.

                memberSearches = _memberSearchesQuery.GetMemberSearches(employerIds, new Range(0, MaxPreviousSearches - searches.Count));
                AddPreviousSearches(searches, employer, from s in memberSearches select s.Criteria, lastMonth);

                // Previous searches.

                if (searches.Count < MaxPreviousSearches)
                {
                    var previousSearches = _memberSearchesQuery.GetMemberSearchExecutions(employerIds, new Range(0, MaxPreviousSearches - searches.Count));
                    AddPreviousSearches(searches, employer, from s in previousSearches select s.Criteria, lastMonth);
                }
            }

            return(searches.Take(MaxPreviousSearches).ToList());
        }
Ejemplo n.º 3
0
        protected void AssertSearches(Employer employer, string expectedDeviceToken, params Tuple <MemberSearch, Tuple <AlertType, bool> >[] expectedSearches)
        {
            var searches = _memberSearchesQuery.GetMemberSearches(employer.Id);

            Assert.AreEqual(expectedSearches.Length, searches.Count);
            foreach (var expectedSearch in expectedSearches)
            {
                var expectedSearchName = expectedSearch.Item1.Name;
                var search             = (from s in searches where s.Name == expectedSearchName select s).Single();
                var isAlert            = _memberSearchAlertsQuery.GetMemberSearchAlert(search.Id, expectedSearch.Item2.Item1) != null;
                AssertSearch(expectedSearch.Item1, expectedSearch.Item2.Item2, search, isAlert);
            }

            AssertDeviceToken(_appleDevicesQuery.GetDevices(employer.Id), expectedDeviceToken);
        }
Ejemplo n.º 4
0
        private void AssertSearches(Guid employerId, ICollection <KeyValuePair <string, string> > areNotAlerts, ICollection <KeyValuePair <string, string> > areAlerts)
        {
            var searches = _memberSearchesQuery.GetMemberSearches(employerId);

            Assert.AreEqual(areNotAlerts.Count + areAlerts.Count, searches.Count);

            var alerts = _memberSearchAlertsQuery.GetMemberSearchAlerts(from s in searches select s.Id, null);

            Assert.AreEqual(areAlerts.Count, alerts.Count);

            foreach (var expectedSearch in areNotAlerts)
            {
                // Must be a search.

                var name   = expectedSearch.Key;
                var search = (from s in searches where s.Name == name select s).SingleOrDefault();
                Assert.IsNotNull(search);
                Assert.AreEqual(expectedSearch.Value, search.Criteria.GetKeywords());

                // Must not be an alert.

                var alert = (from a in alerts where a.MemberSearchId == search.Id select a).SingleOrDefault();
                Assert.IsNull(alert);
            }

            foreach (var expectedSearch in areAlerts)
            {
                // Must be a search.

                var name   = expectedSearch.Key;
                var search = (from s in searches where s.Name == name select s).SingleOrDefault();
                Assert.IsNotNull(search);
                Assert.AreEqual(expectedSearch.Value, search.Criteria.GetKeywords());

                // Must be an alert.

                var alert = (from a in alerts where a.MemberSearchId == search.Id select a).SingleOrDefault();
                Assert.IsNotNull(alert);
            }
        }
Ejemplo n.º 5
0
        private void BindSavedResumeSearchAlertsRepeater()
        {
            // Only include searches that have alerts.

            var searches      = MemberSearchesQuery.GetMemberSearches(LoggedInUserId.Value);
            var alertSearches = from a in MemberSearchAlertsQuery.GetMemberSearchAlerts(from s in searches select s.Id, AlertType.Email) select a.MemberSearchId;

            _items = (from s in searches
                      where alertSearches.Contains(s.Id)
                      select s).ToList();

            if (_items.IsNullOrEmpty())
            {
                EmptyRepeaterMessage.Visible            = true;
                SavedResumeSearchAlertsRepeater.Visible = false; // Needed when a search alert is removed.
                return;
            }

            SavedResumeSearchAlertsRepeater.DataSource = _items;
            SavedResumeSearchAlertsRepeater.DataBind();
            SavedResumeSearchAlertsRepeater.Visible = true;
            Divider.Visible = true;
        }
Ejemplo n.º 6
0
 IList <MemberSearch> IMemberSearchAlertsQuery.GetMemberSearches(Guid ownerId)
 {
     return(_memberSearchesQuery.GetMemberSearches(ownerId));
 }
Ejemplo n.º 7
0
 public ActionResult Searches()
 {
     return(View(_memberSearchesQuery.GetMemberSearches(CurrentEmployer.Id, new Range()).RangeItems));
 }