コード例 #1
0
        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);
                }
            }));
        }