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); } }
public IHttpActionResult GetMyPinsByContactId(PinSearchQueryParams queryParams) { return(Authorized(token => { try { var originCoords = _finderService.GetGeoCoordsFromAddressOrLatLang(queryParams.UserLocationSearchString, queryParams.CenterGeoCoords); var centerLatitude = originCoords.Latitude; var centerLongitude = originCoords.Longitude; var pinsForContact = _finderService.GetMyPins(token, originCoords, queryParams.ContactId, queryParams.FinderType); if (pinsForContact.Count > 0) { var addressLatitude = pinsForContact[0].Address.Latitude; if (addressLatitude != null) { centerLatitude = (double)addressLatitude != 0.0 ? (double)addressLatitude : originCoords.Latitude; } var addressLongitude = pinsForContact[0].Address.Longitude; if (addressLongitude != null) { centerLongitude = (double)addressLongitude != 0.0 ? (double)addressLongitude : originCoords.Longitude; } } var result = new PinSearchResultsDto(new GeoCoordinates(centerLatitude, centerLongitude), pinsForContact); return Ok(result); } catch (Exception ex) { var apiError = new ApiErrorDto("Get Pins for My Stuff Failed", ex); throw new HttpResponseException(apiError.HttpResponseMessage); } })); }