public Paged <Location> SearchByRadiusPaginate(LocationSearchRequest model) { Paged <Location> pagedResult = null; List <Location> result = null; int totalCount = 0; string procName = "[dbo].[Locations_SelectByGeo_V3]"; _data.ExecuteCmd(procName, inputParamMapper : delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@Latitude", model.Latitude); parameterCollection.AddWithValue("@Longitude", model.Latitude); parameterCollection.AddWithValue("@Radius", model.Radius); parameterCollection.AddWithValue("@PageIndex", model.PageIndex); parameterCollection.AddWithValue("@PageSize", model.PageSize); }, singleRecordMapper : delegate(IDataReader reader, short set) { Location aLocation = MapLocation(reader); if (totalCount == 0) { totalCount = reader.GetSafeInt32(17); } if (result == null) { result = new List <Location>(); } result.Add(aLocation); }); if (result != null) { pagedResult = new Paged <Location>(result, model.PageIndex, model.PageSize, totalCount); } return(pagedResult); }
public async Task <IEnumerable <LocationsSearchResult> > GetLocationsAsync(LocationSearchRequest request) { return(await _elasticService.GetLocations(new Location() { lat = request.Lat, lon = request.Lon }, request.MaxDistance, request.MaxResults)); }
public void PostSearch_0Test() { // TODO: add unit test for the method 'PostSearch_0' LocationSearchRequest body = null; // TODO: replace null with proper value var response = instance.PostSearch_0(body); Assert.IsInstanceOf <LocationsSearchResponse> (response, "response is LocationsSearchResponse"); }
private Expression <Func <LocationDTO, bool> > GetQueryFilter(LocationSearchRequest search) { Expression <Func <LocationDTO, bool> > queryFilter = p => true; if (!string.IsNullOrEmpty(search.Name)) { queryFilter = queryFilter.And(p => p.Name.Contains(search.Name)); } if (!string.IsNullOrEmpty(search.Code)) { queryFilter = queryFilter.And(p => p.Code == search.Code); } if (!string.IsNullOrEmpty(search.ZipCode)) { queryFilter = queryFilter.And(p => p.ZipCode == search.ZipCode); } if (search.HasGeofence != null) { queryFilter = queryFilter.And(p => p.HasGeofence == search.HasGeofence); } if (!string.IsNullOrEmpty(search.CountryISOCode)) { queryFilter = queryFilter.And(p => p.CountryISOCode == search.CountryISOCode); } if (!string.IsNullOrEmpty(search.StateCode)) { queryFilter = queryFilter.And(p => p.StateCode == search.StateCode); } if (!string.IsNullOrEmpty(search.CityCode)) { queryFilter = queryFilter.And(p => p.CityCode == search.CityCode); } if (!string.IsNullOrEmpty(search.LocationTypeCode)) { queryFilter = queryFilter.And(p => p.LocationTypeCode == search.LocationTypeCode); } if (!string.IsNullOrEmpty(search.ParentLocationCode)) { queryFilter = queryFilter.And(p => p.ParentLocationCode == search.ParentLocationCode); } return(queryFilter); }
public async Task <IActionResult> Index(LocationSearchRequest searchModel) { var locations = await _locationSearchService.SearchAndSortByGeoAsync( searchModel.Keyword, new GeoPoint(searchModel.Longitude, searchModel.Latitude)); ViewBag.SearchModel = searchModel; return(View(locations)); }
public async Task <IActionResult> Street([FromBody] LocationSearchRequest request) { try { var response = await _locationAppService.GetStreetByWardId(request); return(Json(response)); } catch (Exception e) { _logger.LogError(e, Common.Common.GetMethodName()); throw; } }
public async Task SearchLocation_Call() { //-------------- Arrange ------------- CommonArrangements(); var searchRequest = new LocationSearchRequest(); //-------------- Act ------------- var resp = await locationService.SearchLocationAsync(searchRequest); //-------------- Assert ------------- A.CallTo(() => locationDataAccess.ListPagedAsync(null, 0, 0, null, null)).WithAnyArguments().MustHaveHappened(); }
public SearchResponse Search(SearchRequest request) { var locationSearchRequest = new LocationSearchRequest { Coordinate = request.Coordinate, MaxDistance = request.MaxDistance, MaxResults = request.MaxResults }; var results = _locationSearchService.Search(locationSearchRequest); return(new SearchResponse { Results = results.Results }); }
public async Task <LocationSearchResponse> GetStreetByWardId(LocationSearchRequest request) { LocationSearchResponse response = new LocationSearchResponse(); try { var data = await _locationService.StreetGetByWardIdFromDb(request.WardId); response.LtsStreet = data.Select(x => x.ToModelStreet()).ToArray(); } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <LocationSearchResponse> GetWardByDistricId(LocationSearchRequest request) { LocationSearchResponse response = new LocationSearchResponse(); try { var data = await _locationService.WardGetByDistrictIdFromDb(request.DistricId, request.Name); response.LtsWard = data.Select(x => x.ToModelWard()).ToArray(); } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <LocationSearchResponse> GetDistrcisByProvinceId(LocationSearchRequest request) { LocationSearchResponse response = new LocationSearchResponse(); try { var data = await _locationService.DistrictGetByProvinceIdFromDb(request.ProvinceId, request.Name); response.LtsDictrics = data.Select(x => x.ToModelDistric()).ToArray(); } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <LocationSearchResponse> GetAllProvince(LocationSearchRequest request) { LocationSearchResponse response = new LocationSearchResponse(); try { var data = await _locationService.ProvinceGetAllFromDb(request.Name); response.LtsProvince = data.Select(x => x.ToModel()).ToArray(); } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <LocationDetailResponse> GetDistrictById(LocationSearchRequest request) { LocationDetailResponse response = new LocationDetailResponse(); try { var data = await _locationService.GetDistrictById(request.DistricId); response = data.ToModelDistrictDetail(); } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public LocationSearchResults Search(LocationSearchRequest search) { // TODO: validate search parameter var query = new KnnQuery { Coordinate = search.Coordinate, MaxDistance = search.MaxDistance, MaxResults = search.MaxResults }; // use spatial index to reduce data set var knnQueryResult = _spatialIndex.KnnSearch(query); if (!knnQueryResult.Results.Any()) { return(LocationSearchResults.ZeroResults()); } // now load entities from database var ids = knnQueryResult.Results.Select(i => i.Document.Id).ToArray(); var locations = _locationRepository.FindIn(ids); // build return results by joining Location and Distance var results = new List <LocationSearchResultItem>(); var locationsIndex = locations.ToDictionary(l => l.Id); foreach (var item in knnQueryResult.Results) { if (locationsIndex.ContainsKey(item.Document.Id)) { var location = locationsIndex[item.Document.Id]; results.Add(new LocationSearchResultItem(location, item.Distance)); } } return(LocationSearchResults.Success(results)); }
public async Task <ResponseDTO <PagedList <LocationDTO> > > SearchLocationAsync(LocationSearchRequest search) { List <OrderExpression <LocationDTO> > orderExpressionList = new List <OrderExpression <LocationDTO> >(); orderExpressionList.Add(new OrderExpression <LocationDTO>(OrderType.Asc, p => p.Name)); var queryFilter = GetQueryFilter(search); var location = await _locationDataAccess.ListPagedAsync(queryFilter, search.Page, search.PageSize, orderExpressionList.ToArray()); var pagedResult = new PagedList <LocationDTO>() { Items = location.Items, PageSize = location.PageSize, Page = location.Page, Total = location.Total }; return(ResponseBuilder.Correct(pagedResult)); }
public void Init() { instance = new LocationSearchRequest(); }
public async Task <ResponseDTO <PagedList <LocationDTO> > > Search([FromUri] LocationSearchRequest search) { var resp = await _locationApplicationService.SearchLocationAsync(search); return(resp); }
public ActionResult <ItemResponse <Paged <Location> > > SearchByRadiusPaginate(LocationSearchRequest model) { int code = 200; BaseResponse result = null; try { Paged <Location> page = _service.SearchByRadiusPaginate(model); if (page == null) { code = 404; result = new ErrorResponse("Resource not found."); } else { ItemResponse <Paged <Location> > response = new ItemResponse <Paged <Location> >(); result = new ItemResponse <Paged <Location> > { Item = page }; } } catch (Exception ex) { code = 500; result = new ErrorResponse(ex.Message); base.Logger.LogError(ex.ToString()); } return(StatusCode(code, result)); }