Exemple #1
0
        public ActionResult Searches()
        {
            try
            {
                var employer = CurrentEmployer;
                var searches = _memberSearchAlertsQuery.GetMemberSearches(employer.Id);
                var alerts   = _memberSearchAlertsQuery.GetMemberSearchAlerts(from s in searches select s.Id, AlertType.AppleDevice);

                var model = new MemberSearchesResponseModel
                {
                    TotalSearches  = searches.Count,
                    MemberSearches = (from s in searches
                                      orderby s.CreatedTime descending
                                      select new MemberSearchModel
                    {
                        Id = s.Id,
                        Name = s.Name,
                        IsAlert = alerts.Any(a => a.MemberSearchId == s.Id),
                        Criteria = s.Criteria,
                    }).ToList()
                };

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel(), JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public override void ExecuteTask(string[] args)
        {
            IList <MemberSearchAlert> savedResumeSearches;

            if (args == null || args.Length == 0)
            {
                // Get all saved resume search alerts.

                savedResumeSearches = _memberSearchAlertsQuery.GetMemberSearchAlerts(_alertType);
            }
            else if (args.Length == 1)
            {
                // Get all the saved searches with IDs specified in the argument (separated by commas).

                var idStrings = args[0].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var ids       = idStrings.Select(i => new Guid(i));

                savedResumeSearches = ids.Select(i => _memberSearchAlertsQuery.GetMemberSearchAlert(i, _alertType)).ToList();

                var iNull = savedResumeSearches.IndexOf(null);
                if (iNull != -1)
                {
                    throw new ArgumentException("There is no saved resume search with ID " + idStrings[iNull]);
                }
            }
            else
            {
                throw new ArgumentException("This task expects at most 1 argument: a list of saved search IDs.");
            }

            ExecuteSearchAlerts(savedResumeSearches);
        }
Exemple #3
0
        public void TestUpdateMemberSearch()
        {
            // Create it.

            var owner = new Employer {
                Id = Guid.NewGuid()
            };
            var search = CreateMemberSearch(1);

            _memberSearchAlertsCommand.CreateMemberSearch(owner, search);

            // Update it.

            search.Criteria = CreateCriteria(2);
            _memberSearchAlertsCommand.UpdateMemberSearch(owner, search);

            AssertSearch(search, _memberSearchAlertsQuery.GetMemberSearch(search.Id));
            AssertSearch(search, _memberSearchAlertsQuery.GetMemberSearch(search.OwnerId, search.Name));
            Assert.AreEqual(0, _memberSearchAlertsQuery.GetMemberSearchAlerts(search.Id, null).Count);
        }
Exemple #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);
            }
        }
Exemple #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;
        }