Exemple #1
0
        public void TestDeleteSearchAndAlert()
        {
            var member = CreateMember();

            LogIn(member);

            // Save a search.

            var criteria = new JobAdSearchCriteria();

            criteria.SetKeywords(Keywords);
            var search = new JobAdSearch {
                Criteria = criteria, Name = SearchName
            };

            _jobAdSearchAlertsCommand.CreateJobAdSearchAlert(member.Id, search, DateTime.Now);

            var gotSearch = _jobAdSearchAlertsQuery.GetJobAdSearch(search.Id);

            Assert.AreEqual(SearchName, gotSearch.Name);
            Assert.AreEqual(criteria, gotSearch.Criteria);
            Assert.IsNotNull(_jobAdSearchAlertsQuery.GetJobAdSearchAlert(search.Id));

            // Delete.

            AssertJsonSuccess(DeleteSearch(search.Id));

            // Check.

            Assert.IsNull(_jobAdSearchAlertsQuery.GetJobAdSearch(search.Id));
            Assert.IsNull(_jobAdSearchAlertsQuery.GetJobAdSearchAlert(search.Id));
        }
Exemple #2
0
        public void TestCreateJobAdAlert()
        {
            var ownerId = Guid.NewGuid();
            var search  = CreateJobAdSearch(1);

            _jobAdSearchAlertsCommand.CreateJobAdSearchAlert(ownerId, search, DateTime.Now);

            AssertSearch(search, _jobAdSearchAlertsQuery.GetJobAdSearch(search.Id));
            Assert.IsNotNull(_jobAdSearchAlertsQuery.GetJobAdSearchAlert(search.Id));
        }
Exemple #3
0
        public ActionResult SaveSearch(ContactDetailsModel contactDetails)
        {
            try
            {
                // Save the current search.

                var currentSearch = MemberContext.CurrentSearch;
                if (currentSearch == null)
                {
                    return(JsonNotFound("current search"));
                }

                // Look for a current user.

                var registeredUser = CurrentRegisteredUser;
                if (registeredUser != null)
                {
                    var search = new JobAdSearch {
                        Criteria = currentSearch.Criteria.Clone()
                    };
                    _jobAdSearchAlertsCommand.CreateJobAdSearchAlert(registeredUser.Id, search, DateTime.Now);
                }
                else
                {
                    var anonymousUser = CurrentAnonymousUser;
                    if (anonymousUser != null)
                    {
                        // The owner of the alert is the contact for the anonymous user.

                        var contact = _anonymousUsersCommand.CreateContact(anonymousUser, new ContactDetails {
                            EmailAddress = contactDetails.EmailAddress, FirstName = contactDetails.FirstName, LastName = contactDetails.LastName
                        });
                        var search = new JobAdSearch {
                            Criteria = currentSearch.Criteria.Clone()
                        };
                        _jobAdSearchAlertsCommand.CreateJobAdSearchAlert(contact.Id, search, DateTime.Now);
                    }
                }

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

            return(Json(new JsonResponseModel()));
        }
        public ActionResult SaveSearch(string name, bool createAlert)
        {
            try
            {
                var currentSearch = MemberContext.CurrentSearch;
                if (currentSearch == null)
                {
                    return(NotFound("current search"));
                }

                var search = new JobAdSearch
                {
                    Criteria = currentSearch.Criteria,
                    Name     = name,
                };

                if (createAlert)
                {
                    _jobAdSearchAlertsCommand.CreateJobAdSearchAlert(CurrentMember.Id, search, DateTime.Now);
                }
                else
                {
                    _jobAdSearchesCommand.CreateJobAdSearch(CurrentMember.Id, search);
                }

                return(RedirectToReturnUrlWithConfirmation("SHOW SAVED NOTIFICATION"));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(View(MemberContext.CurrentSearch.Criteria));
        }
Exemple #5
0
        public void TestSavedAlert()
        {
            var member = CreateMember(0);

            LogIn(member);

            var criteria = new JobAdSearchCriteria();

            criteria.SetKeywords(Keywords);
            _jobAdSearchAlertsCommand.CreateJobAdSearchAlert(member.Id, new JobAdSearch {
                Criteria = criteria, Name = SearchName
            }, DateTime.Now);

            Get(_savedSearchesUrl);
            AssertUrl(_savedSearchesUrl);
            AssertNoEmptyText();
            AssertSearches(SearchName);

            Get(_partialSavedSearchesUrl);
            AssertNoEmptyText();
            AssertSearches(SearchName);
        }
Exemple #6
0
        private void CreateTestSavedJobSearchAlert(IHasId <Guid> jobSearcher, string jobTitle, LocationReference location, int?distance, DateTime whenSaved)
        {
            var criteria = new JobAdSearchCriteria
            {
                AdTitle  = jobTitle,
                Location = location,
                Distance = distance
            };

            var execution = new JobAdSearchExecution {
                SearcherId = jobSearcher.Id, Criteria = criteria, Context = "Test"
            };

            execution.Results = _executeJobAdSearchCommand.Search(null, execution.Criteria, null).Results;

            _jobAdSearchesCommand.CreateJobAdSearchExecution(execution);

            var search = new JobAdSearch {
                OwnerId = jobSearcher.Id, Name = "Test Search Alert", Criteria = execution.Criteria.Clone()
            };

            _jobAdSearchAlertsCommand.CreateJobAdSearchAlert(jobSearcher.Id, search, whenSaved);
        }
Exemple #7
0
        private JobAdSearch CreateTestSavedJobSearchAlert(Guid jobSearcherId, string jobTitle, DateTime whenSaved)
        {
            var criteria = new JobAdSearchCriteria
            {
                AdTitle = jobTitle,
            };

            var execution = new JobAdSearchExecution {
                SearcherId = jobSearcherId, Criteria = criteria, Context = "Search"
            };

            execution.Results = _executeJobAdSearchCommand.Search(null, execution.Criteria, null).Results;

            _jobAdSearchesCommand.CreateJobAdSearchExecution(execution);

            var search = new JobAdSearch {
                OwnerId = jobSearcherId, Name = "Test Search Alert", Criteria = execution.Criteria.Clone()
            };

            _jobAdSearchAlertsCommand.CreateJobAdSearchAlert(jobSearcherId, search, whenSaved);

            return(search);
        }