private void MakeOldAlertResult(MemberSearch search, AlertType alertType, bool viewed) { var searchAlert = _memberSearchAlertsQuery.GetMemberSearchAlert(search.Id, alertType); _memberSearchAlertsCommand.AddResults(_employer.Id, new List <SavedResumeSearchAlertResult> { new SavedResumeSearchAlertResult { CandidateId = _member.Id, CreatedTime = DateTime.Now.AddDays(-5), SavedResumeSearchAlertId = searchAlert.Id, Viewed = viewed, } }); }
public ActionResult UnviewedAlertedCandidates() { try { var unviewedCandidates = _memberSearchAlertsQuery.GetUnviewedCandidates(CurrentEmployer.Id); var results = unviewedCandidates.Select(c => c.SavedResumeSearchAlertId).Distinct().Select(i => new SavedSearchResultsModel { SavedSearchId = _memberSearchAlertsQuery.GetMemberSearchAlert(i).MemberSearchId, CandidateIds = (from u in unviewedCandidates where u.SavedResumeSearchAlertId == i select u.CandidateId).ToList(), }).ToList(); var model = new SavedSearchResultsResponseModel { TotalSearches = results.Count(), Searches = results, }; return(Json(model, JsonRequestBehavior.AllowGet)); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(Json(new JsonResponseModel())); }
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); }
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); }
private MemberSearch AssertSearch(Guid employerId, bool isAlert) { var searches = _memberSearchesQuery.GetMemberSearches(employerId); Assert.AreEqual(1, searches.Count); var alert = _memberSearchAlertsQuery.GetMemberSearchAlert(searches[0].Id, AlertType.Email); if (isAlert) { Assert.IsNotNull(alert); } else { Assert.IsNull(alert); } return(searches[0]); }
public void TestCreateMemberSearch() { var owner = new Employer { Id = Guid.NewGuid() }; var search = CreateMemberSearch(1); _memberSearchAlertsCommand.CreateMemberSearch(owner, search); AssertSearch(search, _memberSearchAlertsQuery.GetMemberSearch(search.Id)); AssertSearch(search, _memberSearchAlertsQuery.GetMemberSearch(search.OwnerId, search.Name)); Assert.IsNull(_memberSearchAlertsQuery.GetMemberSearchAlert(search.Id, AlertType.Email)); Assert.IsNull(_memberSearchAlertsQuery.GetMemberSearchAlert(search.Id, AlertType.AppleDevice)); }