Example #1
0
        public IHttpActionResult GetPinsByAddress(PinSearchQueryParams queryParams)
        {
            try
            {
                AwsBoundingBox awsBoundingBox = null;
                Boolean        areAllBoundingBoxParamsPresent = _finderService.areAllBoundingBoxParamsPresent(queryParams.BoundingBox);

                if (areAllBoundingBoxParamsPresent)
                {
                    awsBoundingBox = _awsCloudsearchService.BuildBoundingBox(queryParams.BoundingBox);
                }

                var originCoords = _finderService.GetMapCenterForResults(queryParams.UserLocationSearchString, queryParams.CenterGeoCoords, queryParams.FinderType);

                var pinsInRadius = _finderService.GetPinsInBoundingBox(originCoords, queryParams.UserKeywordSearchString, awsBoundingBox, queryParams.FinderType, queryParams.ContactId, queryParams.UserFilterString);

                pinsInRadius = _finderService.RandomizeLatLongForNonSitePins(pinsInRadius);

                var result = new PinSearchResultsDto(new GeoCoordinates(originCoords.Latitude, originCoords.Longitude), pinsInRadius);

                return(Ok(result));
            }
            catch (InvalidAddressException ex)
            {
                var apiError = new ApiErrorDto("Invalid Address", ex, HttpStatusCode.PreconditionFailed);
                throw new HttpResponseException(apiError.HttpResponseMessage);
            }
            catch (Exception ex)
            {
                var apiError = new ApiErrorDto("Get Pin By Address Failed", ex);
                throw new HttpResponseException(apiError.HttpResponseMessage);
            }
        }