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);
        }
Esempio n. 2
0
 public static void MapTo(this MemberSearch search, SavedResumeSearchEntity entity, ICriteriaPersister criteriaPersister)
 {
     entity.createdTime = search.CreatedTime;
     entity.name        = search.Name;
     entity.ownerId     = search.OwnerId;
     entity.ResumeSearchCriteriaSetEntity = search.Criteria.MapTo <ResumeSearchCriteriaSetEntity, ResumeSearchCriteriaEntity, MemberSearchCriteria>(criteriaPersister, true);
 }
Esempio n. 3
0
 private static void AssertSearch(MemberSearch expectedSearch, MemberSearch search)
 {
     Assert.AreEqual(expectedSearch.Criteria, search.Criteria);
     Assert.AreEqual(expectedSearch.Name, search.Name);
     Assert.AreEqual(expectedSearch.Id, search.Id);
     Assert.AreEqual(expectedSearch.OwnerId, search.OwnerId);
 }
Esempio n. 4
0
        public void TestExecuteSavedSearch()
        {
            // The previous test case doesn't result in the association between MemberSearch and MemberSearchExecution being created
            // because of the initial caching of results.  Explicitly create the MemberSearch here first and then search.

            CreateMember();
            var employer = CreateEmployer();
            var search   = new MemberSearch {
                Name = "My Search", Criteria = new MemberSearchCriteria()
            };

            search.Criteria.SetKeywords(JobTitle);
            _memberSearchesCommand.CreateMemberSearch(employer, search);

            LogIn(employer);

            // Search.

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

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

            AssertUrl(new ReadOnlyApplicationUrl(true, "~/search/candidates/saved/" + savedSearchId));
            AssertSearchExecution(employer.Id, search);
        }
Esempio n. 5
0
        private void UpdateExecutionCriteria(Guid employerId, MemberSearch search)
        {
            var execution = _memberSearchesQuery.GetMemberSearchExecutions(employerId)[0];

            // Update the execution to point to the search's criteria.

            DatabaseHelper.ExecuteNonQuery(
                _connectionFactory,
                "UPDATE dbo.ResumeSearch SET criteriaSetId = @newSetId WHERE criteriaSetId = @oldSetId",
                "@newSetId",
                search.Criteria.Id,
                "@oldSetId",
                execution.Criteria.Id);

            // Delete the existing criteria for the execution.

            DatabaseHelper.ExecuteNonQuery(
                _connectionFactory,
                "DELETE dbo.ResumeSearchCriteria WHERE setId = @setId",
                "@setId",
                execution.Criteria.Id);

            DatabaseHelper.ExecuteNonQuery(
                _connectionFactory,
                "DELETE dbo.ResumeSearchCriteriaSet WHERE id = @setId",
                "@setId",
                execution.Criteria.Id);

            // Check.

            execution = _memberSearchesQuery.GetMemberSearchExecutions(employerId)[0];
            Assert.AreEqual(search.Criteria.Id, execution.Criteria.Id);
        }
Esempio n. 6
0
        private void TestDeleteCriteria(MemberSearchCriteria criteria)
        {
            var owner = new Employer {
                Id = Guid.NewGuid()
            };
            var savedSearch = new MemberSearch {
                Name = SearchName, Criteria = criteria
            };

            _memberSearchesCommand.CreateMemberSearch(owner, savedSearch);

            // Get it.

            var gotSearch = _memberSearchesQuery.GetMemberSearch(savedSearch.Id);

            Assert.IsNotNull(gotSearch);

            var gotSearches = _memberSearchesQuery.GetMemberSearches(savedSearch.OwnerId);

            Assert.AreEqual(1, gotSearches.Count);

            // Delete it.

            _memberSearchesCommand.DeleteMemberSearch(owner, savedSearch.Id);

            gotSearch = _memberSearchesQuery.GetMemberSearch(savedSearch.Id);
            Assert.IsNull(gotSearch);

            gotSearches = _memberSearchesQuery.GetMemberSearches(savedSearch.OwnerId);
            Assert.AreEqual(0, gotSearches.Count);
        }
Esempio n. 7
0
        public override Object Evaluate(Executer exec)
        {
            object[]      args     = new object[this.Arguments.Count];
            System.Type[] argTypes = new Type[this.Arguments.Count];
            for (int i = 0; i < this.Arguments.Count; i++)
            {
                Expression expr = (Expression)this.Arguments[i];
                //terms for functions *always* have an Expression and no Value.
                args[i]     = expr.Evaluate(exec).GetUnboxed(exec);
                argTypes[i] = args[i].GetType();
            }

            if (this.BelongsToObject == null)
            {
                this.BelongsToObject = MemberSearch.FindMethodObject(this.Name, argTypes);
            }

            if (this.BelongsToObject.GetType() == typeof(Nodes.ClassNode))
            {
                Nodes.MethodNode method = ((Nodes.ClassNode) this.BelongsToObject).GetMethod(this.Name);
                //TODO: arguments can't be set like this - another thread may call the same
                //method *while* this call is in execution, so arguments must be put on a stack!
                method.SetArguments(args);
                Executer exe = new Executer(method);
                object   o   = exe.Run();             //method.Execute();
                return(Object.CreateType(o));
            }
            return(Object.CreateType(Endogine.Serialization.Access.CallMethod(
                                         this.BelongsToObject, this.Name, args)));
        }
Esempio n. 8
0
        private void TestUpdateName(string name1, string name2)
        {
            // Create.

            var owner = new Employer {
                Id = Guid.NewGuid()
            };
            var savedSearch = new MemberSearch
            {
                Name     = name1,
                Criteria = CreateAdvancedCriteria(1)
            };

            _memberSearchesCommand.CreateMemberSearch(owner, savedSearch);

            var gotSearch = _memberSearchesQuery.GetMemberSearch(savedSearch.Id);

            Assert.AreEqual(name1, gotSearch.Name);

            // Update.

            savedSearch.Name = name2;

            if (string.IsNullOrEmpty(name2))
            {
                AssertException.Thrown <ValidationErrorsException>(() => _memberSearchesCommand.UpdateMemberSearch(owner, savedSearch), "A 'LinkMe.Framework.Utility.Validation.RequiredValidationError' error has occurred for the Name property.");
            }
            else
            {
                _memberSearchesCommand.UpdateMemberSearch(owner, savedSearch);

                gotSearch = _memberSearchesQuery.GetMemberSearch(savedSearch.Id);
                Assert.AreEqual(name2, gotSearch.Name);
            }
        }
Esempio n. 9
0
        public ActionResult NewSearch(string name, bool isAlert, MemberSearchCriteria criteria, string deviceToken)
        {
            try
            {
                var search = new MemberSearch {
                    Name = name, Criteria = criteria.Clone()
                };
                if (isAlert)
                {
                    _memberSearchAlertsCommand.CreateMemberSearchAlert(CurrentEmployer, search, AlertType.AppleDevice);
                    RegisterDevice(CurrentEmployer.Id, deviceToken);
                }
                else
                {
                    _memberSearchAlertsCommand.CreateMemberSearch(CurrentEmployer, search);
                }

                return(Json(new JsonConfirmationModel {
                    Id = search.Id
                }));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
Esempio n. 10
0
        void IMemberSearchAlertsCommand.UpdateMemberSearch(IUser owner, MemberSearch search, params Tuple <AlertType, bool>[] alertMethods)
        {
            // Update the search.

            _memberSearchesCommand.UpdateMemberSearch(owner, search);

            // Check whether each alert already exists.

            foreach (var method in alertMethods)
            {
                var alertType = method.Item1;
                var alert     = _repository.GetMemberSearchAlert(search.Id, alertType);
                if (method.Item2)
                {
                    if (alert == null)
                    {
                        CreateMemberSearchAlert(search, alertType);
                    }
                }
                else
                {
                    if (alert != null)
                    {
                        DeleteMemberSearchAlert(search, alertType);
                    }
                }
            }
        }
Esempio n. 11
0
        public void TestUpdateSameName()
        {
            var owner = new Employer {
                Id = Guid.NewGuid()
            };

            // Create 2 searches.

            var savedSearch1 = new MemberSearch
            {
                Name     = "TestName1",
                Criteria = CreateAdvancedCriteria(1)
            };

            _memberSearchesCommand.CreateMemberSearch(owner, savedSearch1);

            var savedSearch2 = new MemberSearch
            {
                Name     = "TestName2",
                Criteria = CreateAdvancedCriteria(2)
            };

            _memberSearchesCommand.CreateMemberSearch(owner, savedSearch2);

            // Update the second to match the first.

            savedSearch2.Name = savedSearch1.Name;
            AssertException.Thrown <ValidationErrorsException>(() => _memberSearchesCommand.UpdateMemberSearch(owner, savedSearch2), "A 'LinkMe.Framework.Utility.Validation.DuplicateValidationError' error has occurred for the Name property.");
        }
Esempio n. 12
0
        public void TestSameName()
        {
            var employer = CreateEmployer(0);

            LogIn(employer);

            var criteria = new MemberSearchCriteria();

            criteria.SetKeywords(Keywords);
            var search0 = new MemberSearch {
                Name = string.Format(NameFormat, 0), Criteria = criteria
            };

            AssertJsonSuccess(NewSearch(search0, false, string.Empty));

            // Create another.

            var search1 = new MemberSearch {
                Name = search0.Name, Criteria = criteria
            };

            AssertJsonError(NewSearch(search1, false, string.Empty), "Name", "The name is already being used.");

            AssertSearches(Searches(), MakeTupleTuple(search0, AlertType.AppleDevice, false));
            AssertSearches(employer, string.Empty, MakeTupleTuple(search0, AlertType.AppleDevice, false));
        }
        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());
        }
        public void TestEmailContents()
        {
            // Create an employer and search.

            var employer = CreateEmployer(0, true);
            var criteria = new MemberSearchCriteria
            {
                JobTitle = JobTitle,
                Location = _location,
                Salary   = new Salary {
                    LowerBound = 100000, UpperBound = 200000, Rate = SalaryRate.Year, Currency = Currency.AUD
                },
                JobTypes = JobTypes.Contract,
            };

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

            // Create some results.

            var results = CreateResults(1, false, false, false);

            // Send.

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

            // Check.

            AssertMail(email, employer, search, results, 0, 0, false);
        }
Esempio n. 15
0
        public void TestDeleteSearchSharedCriteria()
        {
            var owner = new Employer {
                Id = Guid.NewGuid()
            };

            // For some older searches the criteria are shared between searches.

            var search1 = new MemberSearch {
                Name = SearchName, Criteria = CreateAdvancedCriteria(0)
            };

            _memberSearchesCommand.CreateMemberSearch(owner, search1);

            var search2 = new MemberSearch {
                Name = SearchName2, Criteria = CreateAdvancedCriteria(0)
            };

            _memberSearchesCommand.CreateMemberSearch(owner, search2);

            UpdateCriteriaId(search1.Id, search2.Criteria.Id);

            // Now delete the first.

            _memberSearchesCommand.DeleteMemberSearch(owner, search1.Id);

            Assert.IsNull(_memberSearchesQuery.GetMemberSearch(search1.Id));
            AssertSearch(search2, _memberSearchesQuery.GetMemberSearch(search2.Id));
        }
Esempio n. 16
0
        public void TestNoName()
        {
            var employer = CreateEmployer(0);
            var criteria = new MemberSearchCriteria();

            criteria.SetKeywords(Keywords);
            var search = new MemberSearch {
                Name = string.Format(NameFormat, 0), Criteria = criteria
            };

            _memberSearchAlertsCommand.CreateMemberSearch(employer, search);
            CreateDevice(employer.Id, "BogusDeviceToken");

            LogIn(employer);
            AssertSearches(Searches(), MakeTupleTuple(search, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken", MakeTupleTuple(search, AlertType.AppleDevice, false));

            var originalName = search.Name;

            search.Name = null;
            AssertJsonError(EditSearch(search, false, "BogusDeviceToken"), "Name", "The name is required.");

            search.Name = originalName;
            AssertSearches(Searches(), MakeTupleTuple(search, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken", MakeTupleTuple(search, AlertType.AppleDevice, false));
        }
Esempio n. 17
0
        public void TestDeleteSearchExecutionSharedCriteria()
        {
            var owner = new Employer {
                Id = Guid.NewGuid()
            };

            // For some older searches the criteria are shared between searches and executions.

            var search = new MemberSearch {
                Name = SearchName, Criteria = CreateAdvancedCriteria(0)
            };

            _memberSearchesCommand.CreateMemberSearch(owner, search);

            var execution = new MemberSearchExecution {
                Criteria = CreateAdvancedCriteria(0), Results = new MemberSearchResults(), Context = "xxx"
            };

            _memberSearchesCommand.CreateMemberSearchExecution(execution);

            UpdateCriteriaId(search.Id, execution.Criteria.Id);

            // Delete.

            _memberSearchesCommand.DeleteMemberSearch(owner, search.Id);

            Assert.IsNull(_memberSearchesQuery.GetMemberSearch(search.Id));
            AssertExecution(execution, _memberSearchesQuery.GetMemberSearchExecution(execution.Id));
        }
Esempio n. 18
0
        public void TestSameName()
        {
            var employer = CreateEmployer(0);
            var criteria = new MemberSearchCriteria();

            criteria.SetKeywords(Keywords);
            var search0 = new MemberSearch {
                Name = string.Format(NameFormat, 0), Criteria = criteria.Clone()
            };

            _memberSearchAlertsCommand.CreateMemberSearch(employer, search0);
            CreateDevice(employer.Id, "BogusDeviceToken");

            var search1 = new MemberSearch {
                Name = string.Format(NameFormat, 1), Criteria = criteria.Clone()
            };

            _memberSearchAlertsCommand.CreateMemberSearch(employer, search1);

            LogIn(employer);
            AssertSearches(Searches(), MakeTupleTuple(search0, AlertType.AppleDevice, false), MakeTupleTuple(search1, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken", MakeTupleTuple(search0, AlertType.AppleDevice, false), MakeTupleTuple(search1, AlertType.AppleDevice, false));

            // Update it to another.

            var originalName = search1.Name;

            search1.Name = search0.Name;
            AssertJsonError(EditSearch(search1, false, "BogusDeviceToken"), "Name", "The name is already being used.");

            search1.Name = originalName;
            AssertSearches(Searches(), MakeTupleTuple(search0, AlertType.AppleDevice, false), MakeTupleTuple(search1, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken", MakeTupleTuple(search0, AlertType.AppleDevice, false), MakeTupleTuple(search1, AlertType.AppleDevice, false));
        }
Esempio n. 19
0
        public PagedResult <MemberListItem> GetMembers(
            int pageNumber           = 1,
            int pageSize             = 100,
            string orderBy           = "email",
            Direction orderDirection = Direction.Ascending,
            string filter            = "")
        {
            if (pageNumber <= 0 || pageSize <= 0)
            {
                throw new NotSupportedException("Both pageNumber and pageSize must be greater than zero");
            }

            var queryString     = Request.GetQueryNameValuePairs();
            var memberTypeAlias = GetMemberType(queryString);
            var filters         = GetFilters(queryString);

            var members = MemberSearch.PerformMemberSearch(filter, filters, out int totalRecords,
                                                           memberTypeAlias, pageNumber, pageSize,
                                                           orderBy, orderDirection);

            if (totalRecords == 0)
            {
                return(new PagedResult <MemberListItem>(0, 0, 0));
            }

            var pagedResult = new PagedResult <MemberListItem>(totalRecords, pageNumber, pageSize)
            {
                Items = members
                        .Select(x => AutoMapperExtensions.MapWithUmbracoContext <SearchResult, MemberListItem>(x, UmbracoContext))
            };

            return(pagedResult);
        }
Esempio n. 20
0
        public void TestEditSearch()
        {
            var employer = CreateEmployer(0);
            var criteria = new MemberSearchCriteria();

            criteria.SetKeywords(Keywords);
            var search = new MemberSearch {
                Name = string.Format(NameFormat, 0), Criteria = criteria
            };

            _memberSearchAlertsCommand.CreateMemberSearch(employer, search);
            CreateDevice(employer.Id, "BogusDeviceToken");

            LogIn(employer);
            AssertSearches(Searches(), MakeTupleTuple(search, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken", MakeTupleTuple(search, AlertType.AppleDevice, false));

            // Update the name.

            search.Name = string.Format(NameFormat, 1);
            AssertJsonSuccess(EditSearch(search, false, "BogusDeviceToken2"));
            AssertSearches(Searches(), MakeTupleTuple(search, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken2", MakeTupleTuple(search, AlertType.AppleDevice, false));

            // Update the criteria.

            criteria.SetKeywords(NewKeywords);
            search.Criteria = criteria;
            AssertJsonSuccess(EditSearch(search, false, "BogusDeviceToken2"));
            AssertSearches(Searches(), MakeTupleTuple(search, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken2", MakeTupleTuple(search, AlertType.AppleDevice, false));
        }
        public object GetMemberListSyncIOS(MemberSearch member)
        {
            dynamic MemberDirectorResult;

            try
            {
                string zipFilePath, FileName;
                MemberListSyncResult memberListSyncResult = MemberMaster.GetMemberListSyncIOS(member.updatedOn, member.grpID, out zipFilePath, out FileName);
                FileName = "Profile" + FileName + ".zip";
                if (!string.IsNullOrEmpty(zipFilePath))
                {
                    MemberDirectorResult = new { status = "0", message = "success", curDate = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), zipFilePath, FileName, memberListSyncResult };
                }
                else if (memberListSyncResult.NewMemberList.Count == 0 && memberListSyncResult.UpdatedMemberList.Count == 0 && string.IsNullOrEmpty(memberListSyncResult.DeletedMemberList))
                {
                    MemberDirectorResult = new { status = "2", message = "No New Updates", curDate = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), zipFilePath, FileName, memberListSyncResult };
                }
                else
                {
                    MemberDirectorResult = new { status = "0", message = "success", curDate = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), zipFilePath, FileName, memberListSyncResult };
                }
            }
            catch (Exception ex)
            {
                MemberDirectorResult = new { status = "1", error = ex.ToString(), message = "An error occured. Please contact Administrator", curDate = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") };
            }
            return(MemberDirectorResult);
        }
Esempio n. 22
0
        public void TestEditSearchAlert()
        {
            var employer = CreateEmployer(0);
            var criteria = new MemberSearchCriteria();

            criteria.SetKeywords(Keywords);
            var search = new MemberSearch {
                Name = string.Format(NameFormat, 0), Criteria = criteria
            };

            _memberSearchAlertsCommand.CreateMemberSearch(employer, search);
            CreateDevice(employer.Id, "BogusDeviceToken");

            LogIn(employer);
            AssertSearches(Searches(), MakeTupleTuple(search, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken", MakeTupleTuple(search, AlertType.AppleDevice, false));

            // Turn into an alert.

            AssertJsonSuccess(EditSearch(search, true, "BogusDeviceToken4"));
            AssertSearches(Searches(), MakeTupleTuple(search, AlertType.AppleDevice, true));
            AssertSearches(employer, "BogusDeviceToken4", MakeTupleTuple(search, AlertType.AppleDevice, true));

            // Delete alert.

            AssertJsonSuccess(EditSearch(search, false, "BogusDeviceToken"));
            AssertSearches(Searches(), MakeTupleTuple(search, AlertType.AppleDevice, false));
            AssertSearches(employer, "BogusDeviceToken", MakeTupleTuple(search, AlertType.AppleDevice, false));
        }
Esempio n. 23
0
 private void AssertNoSearchPages(MemberSearch search)
 {
     GetPage <SavedResumeSearches>();
     AssertPageDoesNotContain(search.GetDisplayHtml());
     GetPage <SavedResumeSearchAlerts>();
     AssertPageDoesNotContain(search.GetDisplayHtml());
 }
        private void AssertNotifications(MemberSearch search, AlertType alertType, int expectedCount)
        {
            var searchAlert = _memberSearchAlertsQuery.GetMemberSearchAlert(search.Id, alertType);
            var results     = _memberSearchAlertsQuery.GetAlertResults(searchAlert.Id);

            Assert.AreEqual(expectedCount, results.Count);
        }
Esempio n. 25
0
        public PagedResponse <MemberDto> Execute(MemberSearch search)
        {
            var query = _context.Members.AsQueryable().DefaultFilter(search);

            if (!string.IsNullOrEmpty(search.FirstName) || !string.IsNullOrWhiteSpace(search.FirstName))
            {
                query = query.Where(x => x.FirstName.ToLower().Contains(search.FirstName.ToLower()));
            }

            if (!string.IsNullOrEmpty(search.LastName) || !string.IsNullOrWhiteSpace(search.LastName))
            {
                query = query.Where(x => x.LastName.ToLower().Contains(search.LastName.ToLower()));
            }

            if (!string.IsNullOrEmpty(search.Email) || !string.IsNullOrWhiteSpace(search.Email))
            {
                query = query.Where(x => x.Email.ToLower().Contains(search.Email.ToLower()));
            }

            if (!string.IsNullOrEmpty(search.Phone) || !string.IsNullOrWhiteSpace(search.Phone))
            {
                query = query.Where(x => x.Phone.ToLower().Contains(search.Phone.ToLower()));
            }

            if (search.MemberCardNumber.HasValue)
            {
                query = query.Where(x => x.MemberCardNumber.ToString().Contains(search.MemberCardNumber.ToString()));
            }

            return(query.Paged <MemberDto, Domain.Member>(search, _mapper));
        }
Esempio n. 26
0
        public PagedResult <MemberListItem> GetMembers(FormDataCollection queryStrings)
        {
            // Base Query data
            int       pageNumber     = queryStrings.HasKey("pageNumber") ? queryStrings.GetValue <int>("pageNumber") : 1;
            int       pageSize       = queryStrings.HasKey("pageSize") ? queryStrings.GetValue <int>("pageSize") : 10;
            string    orderBy        = queryStrings.HasKey("orderBy") ? queryStrings.GetValue <string>("orderBy") : "email";
            Direction orderDirection = queryStrings.HasKey("orderDirection") ? queryStrings.GetValue <Direction>("orderDirection") : Direction.Ascending;
            string    memberType     = queryStrings.HasKey("memberType") ? queryStrings.GetValue <string>("memberType") : "";

            string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue <string>("filter") : "";

            int totalMembers = 0;
            var members      = Mapper.Map <IEnumerable <MemberListItem> >(MemberSearch.PerformMemberSearch(filter, queryStrings, out totalMembers,
                                                                                                           memberType, pageNumber, pageSize,
                                                                                                           orderBy, orderDirection));

            if (totalMembers == 0)
            {
                return(new PagedResult <MemberListItem>(0, 0, 0));
            }

            var pagedResult = new PagedResult <MemberListItem>(
                totalMembers,
                pageNumber,
                pageSize);

            pagedResult.Items = members;

            return(pagedResult);
        }
Esempio n. 27
0
        private void TestUpdate(MemberSearchCriteria criteria1, MemberSearchCriteria criteria2)
        {
            // Create first.

            var owner = new Employer { Id = Guid.NewGuid() };
            var savedSearch = new MemberSearch { Name = SearchName, Criteria = criteria1 };
            _memberSearchesCommand.CreateMemberSearch(owner, savedSearch);

            // Get it.

            var gotSearch = _memberSearchesQuery.GetMemberSearch(savedSearch.Id);
            Assert.AreEqual(criteria1, gotSearch.Criteria);

            var gotSearches = _memberSearchesQuery.GetMemberSearches(savedSearch.OwnerId);
            Assert.AreEqual(1, gotSearches.Count);
            Assert.AreEqual(criteria1, gotSearches[0].Criteria);

            // Update it.

            savedSearch.Criteria = criteria2;
            _memberSearchesCommand.UpdateMemberSearch(owner, savedSearch);

            // Get it.

            gotSearch = _memberSearchesQuery.GetMemberSearch(savedSearch.Id);
            Assert.AreEqual(criteria2, gotSearch.Criteria);

            gotSearches = _memberSearchesQuery.GetMemberSearches(savedSearch.OwnerId);
            Assert.AreEqual(1, gotSearches.Count);
            Assert.AreEqual(criteria2, gotSearches[0].Criteria);
        }
Esempio n. 28
0
        public HttpResponseMessage GetMembersExport(FormDataCollection queryStrings)
        {
            // Base Query data
            string    memberType     = queryStrings.HasKey("memberType") ? queryStrings.GetValue <string>("memberType") : "";
            string    orderBy        = queryStrings.HasKey("orderBy") ? queryStrings.GetValue <string>("orderBy") : "email";
            Direction orderDirection = queryStrings.HasKey("orderDirection") ? queryStrings.GetValue <Direction>("orderDirection") : Direction.Ascending;

            string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue <string>("filter") : "";

            int totalMembers = 0;

            var members = Mapper.Map <IEnumerable <MemberExportModel> >(MemberSearch.PerformMemberSearch(filter, queryStrings, out totalMembers,
                                                                                                         memberType,
                                                                                                         orderBy: orderBy,
                                                                                                         orderDirection: orderDirection));

            var content = members.CreateCSV();

            // see http://stackoverflow.com/questions/9541351/returning-binary-file-from-controller-in-asp-net-web-api
            // & http://stackoverflow.com/questions/12975886/how-to-download-a-file-using-web-api-in-asp-net-mvc-4-and-jquery
            // We really should use an async version - the above reference includes an example.
            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);

            result.Content = new StringContent(content);
            result.Content.Headers.ContentType                 = new MediaTypeHeaderValue("application/octet-stream");
            result.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            result.Content.Headers.ContentDisposition.FileName = string.Format("Members_{0:yyyyMMdd}.csv", DateTime.Now);

            return(result);
        }
Esempio n. 29
0
 void IMemberSearchesCommand.CreateMemberSearch(IUser owner, MemberSearch search)
 {
     search.OwnerId = owner.Id;
     search.Prepare();
     search.Validate();
     _repository.CreateMemberSearch(search);
 }
        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);
        }