private HttpResponseMessage RetreiveSearchItemsFromAdvancedSearchPage(string brand, string minPrice, string maxPrice, string minMp, string maxMp) { HttpResponseMessage response; using (var client = new HttpClient()) { client.BaseAddress = new Uri(ConfigurationManager.AppSettings["ApiBaseUrl"]); var command = new AdvancedSearchParameters { Brand = brand, MinPrice = minPrice, MaxPrice = maxPrice, MinMp = minMp, MaxMp = maxMp }; var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; var jsonCommand = JsonConvert.SerializeObject(command, settings); response = client.PostAsync("advanced-search", new StringContent(jsonCommand, Encoding.UTF8, "application/json")).Result; } return(response); }
public void PersistCardSearchHistory(AdvancedSearchParameters searchParams, DateTime createdDateTime, DateTime updatedDateTime) { var cardSearchHistoryModel = GetCardSearchHistoryModel(searchParams, createdDateTime, updatedDateTime); var cardSearchHistory = GetCardSearchHistory(cardSearchHistoryModel); _context.CardSearchHistories.Add(cardSearchHistory); _context.SaveChanges(); }
/// <summary> /// Advanced search /// </summary> /// <param name="searchParameters">The search parameters</param> /// <returns><see cref="AdvancedSearchResultCollection"/></returns> public AdvancedSearchResultCollection AdvancedSearch(AdvancedSearchParameters searchParameters) { if (string.IsNullOrEmpty(searchParameters.Name)) { throw new ArgumentNullException(nameof(searchParameters.Name)); } var results = new AdvancedSearchResultCollection { SearchResults = new List <AdvancedSearchResult>() }; var foundPerson = _placePersonCollection.people.FirstOrDefault(p => string.Compare(p.name, searchParameters.Name.Trim(), true) == 0); if (foundPerson != null) { IEnumerable <Person> people = null; List <Person> hierarchy = new List <Person>(); hierarchy.Add(foundPerson); if (searchParameters.Direction == Direction.Ancestors) { people = FindByDirection(_placePersonCollection.people.Where(p => p.id == foundPerson.father_id || p.id == foundPerson.mother_id), searchParameters.Gender, searchParameters.Direction, hierarchy); } else { people = FindByDirection(_placePersonCollection.people.Where(p => p.father_id == foundPerson.id || p.mother_id == foundPerson.id), searchParameters.Gender, searchParameters.Direction, hierarchy); } var query = people.Join(_placePersonCollection.places, p => p.place_id, p => p.id, (p, pl) => new AdvancedSearchResult { ID = p.id, Name = p.name, Gender = p.gender, Level = p.level, BirthPlace = pl.name }).AsQueryable(); if (searchParameters.Direction == Direction.Ancestors) { query = query.OrderByDescending(asr => asr.Level).ThenBy(asr => asr.Name); } else { query = query.OrderBy(asr => asr.Level).ThenBy(asr => asr.Name); } results.SearchResults = query.Take(this.MaxNoOfSearchResults).ToList(); } return(results); }
public void TestFindByProxId() { string personId = "362208862"; string proxId = "08634"; AdvancedSearchParameters parameters = new AdvancedSearchParameters(); parameters.ProxNumber = proxId; PersonServiceResponse response = manager.DoAdvancedSearch(parameters); Assert.IsNotNull(response); Assert.IsTrue(response.PageCount == 1); Assert.IsTrue(response.TotalSize == 1); Assert.AreEqual(personId, response.Results[0].PersonId); }
public JsonResult OnPostSearchCardsAsync(Guid setId, string searchText, string sortBy, string sortOrder) { try { var websiteSource = _sourceService.GetSource(SourceType.Website); var cards = new List <CardModel>(); var isAdvancedSearch = _advancedCardSearchService.IsAdvancedSearch(searchText); if (isAdvancedSearch) { var advancedSearchParamters = new AdvancedSearchParameters() { AdvancedSearchText = searchText, SortBy = sortBy, SortOrder = sortOrder, //Harding coding English for now, as we don't have other languages atm LanguageId = new Guid("4F5CC98D-4315-4410-809F-E2CC428E0C9B"), }; cards = _advancedCardSearchService.SearchCards(advancedSearchParamters); } else { var cardSearchParameters = new CardSearchParameters() { SetId = setId, SearchText = searchText, SortBy = sortBy, SortOrder = sortOrder, //Harding coding English for now, as we don't have other languages atm LanguageId = new Guid("4F5CC98D-4315-4410-809F-E2CC428E0C9B"), SourceId = websiteSource.SourceId, }; cards = _cardService.SearchCards(cardSearchParameters); } return(new JsonResult(new { success = true, json = cards })); } catch (Exception ex) { return(new JsonResult(new { success = false, json = ex.Message })); } }
public void TestAdvancedSearch() { string lookupQuery = "kleinman"; PersonServiceResponse response = manager.LookupPerson(lookupQuery); Assert.IsTrue(response.PageCount >= 4); Assert.IsTrue(response.TotalSize >= 101); PersonServiceResponse response2 = manager.LookupPerson(2, lookupQuery, "*"); PersonServiceResponse response3 = manager.LookupPerson(3, lookupQuery, "*"); AdvancedSearchParameters parameters = new AdvancedSearchParameters(); parameters.LastName = lookupQuery; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(response.TotalSize >= 101); Assert.IsTrue(response.Results.Count == response.TotalSize); parameters.LastName = "reedk2"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(response.TotalSize == 1); }
private CardSearchHistoryModel GetCardSearchHistoryModel(AdvancedSearchParameters searchParams, DateTime createdDateTime, DateTime updatedDateTime) { var userId = searchParams.PerformedByUserId == null ? Guid.Empty : (Guid)searchParams.PerformedByUserId; return(new CardSearchHistoryModel() { CardSearchHistoryId = Guid.NewGuid(), UserId = userId, SearchText = searchParams.AdvancedSearchText, LanguageId = searchParams.LanguageId, SortBy = searchParams.SortBy, SortOrder = searchParams.SortOrder, SourceId = searchParams.SourceId, CreatedById = userId, CreatedDate = createdDateTime, UpdatedById = userId, UpdatedDate = updatedDateTime, Deleted = false, }); }
public AdvancedSearchResultCollection AdvancedSearch([FromBody] AdvancedSearchParameters searchParameters) { return(_ancestryRepository.AdvancedSearch(searchParameters)); }
public void TestComplexSearches() { AdvancedSearchParameters parameters = new AdvancedSearchParameters(); parameters.PersonId = "not null"; parameters.ByuId = "not null"; parameters.NetId = "not null"; parameters.SSN = "not null"; parameters.ProxNumber = "not null"; parameters.LastName = "not null"; parameters.FirstName = "nut null"; parameters.Email = "not null"; parameters.PhoneNumber = "not null"; // PersonID should take precedence PersonServiceResponse response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_PERSON_ID) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // NetID should take precedence ResetCallCounts(); parameters.PersonId = null; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_SINGLE_QUERY) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // BYU ID should take precedence ResetCallCounts(); parameters.NetId = null; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_SINGLE_QUERY) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // SSN should take precedence ResetCallCounts(); parameters.ByuId = null; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_SINGLE_QUERY) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Prox # should take precedence ResetCallCounts(); parameters.SSN = null; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_PERSON_ID) == 1); Assert.IsTrue(idClient.GetCallCount(IdCardClientOperation.GET_PERSON_ID_BY_PROX_ID) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 1); // Should search combinations of last, first, email and phone // Searching last, first, email and phone ResetCallCounts(); parameters.ProxNumber = null; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 3); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_EMAIL) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_ENGINE_AND_QUERY_PAGED) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching first, email and phone ResetCallCounts(); parameters.LastName = null; parameters.FirstName = "not null"; parameters.Email = "not null"; parameters.PhoneNumber = "not null"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 3); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_EMAIL) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_ENGINE_AND_QUERY_PAGED) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching last, email and phone ResetCallCounts(); parameters.LastName = "not null"; parameters.FirstName = null; parameters.Email = "not null"; parameters.PhoneNumber = "not null"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 3); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_EMAIL) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_ENGINE_AND_QUERY_PAGED) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching last, first, and phone ResetCallCounts(); parameters.LastName = "not null"; parameters.FirstName = "not null"; parameters.Email = null; parameters.PhoneNumber = "not null"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 2); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_ENGINE_AND_QUERY_PAGED) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching last, first, and email ResetCallCounts(); parameters.LastName = "not null"; parameters.FirstName = "not null"; parameters.Email = "not null"; parameters.PhoneNumber = null; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 2); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_EMAIL) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching last and phone ResetCallCounts(); parameters.LastName = "not null"; parameters.FirstName = null; parameters.Email = null; parameters.PhoneNumber = "not null"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 2); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_ENGINE_AND_QUERY_PAGED) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching first and phone ResetCallCounts(); parameters.LastName = null; parameters.FirstName = "not null"; parameters.Email = null; parameters.PhoneNumber = "not null"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 2); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_ENGINE_AND_QUERY_PAGED) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching last and email ResetCallCounts(); parameters.LastName = "not null"; parameters.FirstName = null; parameters.Email = "not null"; parameters.PhoneNumber = null; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 2); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_EMAIL) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching first and email ResetCallCounts(); parameters.LastName = "not null"; parameters.FirstName = null; parameters.Email = "not null"; parameters.PhoneNumber = null; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 2); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_EMAIL) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); // Searching email and phone ResetCallCounts(); parameters.LastName = null; parameters.FirstName = null; parameters.Email = "not null"; parameters.PhoneNumber = "not null"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 2); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_EMAIL) == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_ENGINE_AND_QUERY_PAGED) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); }
public void TestSingleItemSearches() { AdvancedSearchParameters parameters = new AdvancedSearchParameters(); // Search by each field individually parameters.PersonId = TEST_PERSON_ID; PersonServiceResponse response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_PERSON_ID) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); ResetCallCounts(); parameters = new AdvancedSearchParameters(); parameters.ByuId = "string"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_SINGLE_QUERY) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); ResetCallCounts(); parameters = new AdvancedSearchParameters(); parameters.NetId = "string"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_SINGLE_QUERY) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); ResetCallCounts(); parameters = new AdvancedSearchParameters(); parameters.SSN = "string"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_SINGLE_QUERY) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); ResetCallCounts(); parameters = new AdvancedSearchParameters(); parameters.ProxNumber = "string"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_PERSON_ID) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 1); ResetCallCounts(); parameters = new AdvancedSearchParameters(); parameters.LastName = "string"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); ResetCallCounts(); parameters = new AdvancedSearchParameters(); parameters.FirstName = "string"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_QUERY_AND_MODIFIER) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); ResetCallCounts(); parameters = new AdvancedSearchParameters(); parameters.Email = "string"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_EMAIL) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); ResetCallCounts(); parameters = new AdvancedSearchParameters(); parameters.PhoneNumber = "string"; response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 1); Assert.IsTrue(lookupClient.GetCallCount(LookupOperation.BY_ENGINE_AND_QUERY_PAGED) == 1); Assert.IsTrue(idClient.GetTotalCallCount() == 0); }
public void TestGarbageSearches() { PersonServiceResponse response = manager.DoAdvancedSearch(null); Assert.IsTrue(lookupClient.GetTotalCallCount() == 0); AdvancedSearchParameters parameters = new AdvancedSearchParameters(); response = manager.DoAdvancedSearch(parameters); Assert.IsTrue(lookupClient.GetTotalCallCount() == 0); }