public async Task <IActionResult> Index(string keyword) { var viewModel = new List <SearchViewModel>(); var result = await searchApi.Search(keyword); result.ForEach(item => { var mp = mapper.Map <SearchViewModel>(item); viewModel.Add(mp); }); return(View("Search", viewModel)); }
public async Task <IActionResult> Search(string keyword) { var viewModel = new List <SearchViewModel>(); var searchResult = await _searchApiClient.Search(keyword); searchResult.ForEach(advertDoc => { var viewModelItem = _mapper.Map <SearchViewModel>(advertDoc); viewModel.Add(viewModelItem); }); return(View("Search", viewModel)); }
public async Task <IActionResult> Index(string keyword) { ViewBag.Current = "Home"; var searchResults = new List <SearchViewModel>(); if (string.IsNullOrWhiteSpace(keyword)) { return(View(searchResults)); } var ads = await _searchApiClient.Search(keyword).ConfigureAwait(false); ads.ForEach(ad => { searchResults.Add(new SearchViewModel(ad)); }); return(View(searchResults)); }
public async Task <SearchRequestViewModel> Search(SearchRequestViewModel vm) { var epaOrgId = _contextAccessor.HttpContext.User.FindFirst("http://schemas.portal.com/epaoid")?.Value; var username = _contextAccessor.HttpContext.User .FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn")?.Value; var results = await _searchApiClient.Search(new SearchQuery() { Surname = vm.Surname, Uln = long.Parse(vm.Uln), EpaOrgId = epaOrgId, Username = username }); var viewModelSearchResults = new List <ResultViewModel>(); foreach (var result in results) { viewModelSearchResults.Add(new ResultViewModel { GivenNames = result.GivenNames, FamilyName = result.FamilyName, Uln = Convert.ToString(result.Uln), Standard = result.Standard, StdCode = Convert.ToString(result.StdCode), Version = result.Version, VersionConfirmed = result.VersionConfirmed, Versions = Mapper.Map <List <StandardVersionViewModel> >(result.Versions), OverallGrade = result.OverallGrade, CertificateReference = result.CertificateReference, CertificateStatus = result.CertificateStatus, IsPrivatelyFunded = result.IsPrivatelyFunded, Level = Convert.ToString(result.Level), SubmittedAt = result.SubmittedAt, SubmittedBy = result.SubmittedBy, AchDate = result.AchDate, LearnStartDate = result.LearnStartDate, ShowExtraInfo = result.ShowExtraInfo, UlnAlreadyExists = result.UlnAlreadyExits, IsNoMatchingFamilyName = result.IsNoMatchingFamilyName }); } vm.SearchResults = viewModelSearchResults; return(vm); }
public SearchFightResponse SearchFight(List <string> queries) { if (queries.Count == 0) { return(new SearchFightResponse()); } var queriesResults = new List <SearchResponse>(); foreach (var query in queries) { var googleResult = _googleSearchEngineApiClient.Search(query); var bingResult = _bingSearchEngineApiClient.Search(query); queriesResults.Add(new SearchResponse { Query = query, GoogleTotalResults = googleResult.StatusCode == HttpStatusCode.OK ? long.Parse(googleResult.Data.SearchInformation.TotalResults) : 0, BingTotalResults = bingResult.StatusCode == HttpStatusCode.OK ? bingResult.Data.WebPages.TotalEstimatedMatches : 0 }); } return(SelectWinners(queriesResults)); }