Beispiel #1
0
        public IHttpActionResult GetPinDetailsByContact([FromUri] int contactId, [FromUri] bool throwOnEmptyCoordinates = true)
        {
            try
            {
                var participantId = _finderService.GetParticipantIdFromContact(contactId);
                //refactor this to JUST get location;
                var  pin = _finderService.GetPinDetailsForPerson(participantId);
                bool pinHasInvalidGeoCoords = ((pin.Address == null) || (pin.Address.Latitude == null || pin.Address.Longitude == null) ||
                                               (pin.Address.Latitude == 0 && pin.Address.Longitude == 0));

                if (pinHasInvalidGeoCoords && throwOnEmptyCoordinates)
                {
                    return(Content(HttpStatusCode.ExpectationFailed, "Invalid Latitude/Longitude"));
                }
                pin.Address = _finderService.RandomizeLatLong(pin.Address);
                return(Ok(pin));
            }
            catch (Exception ex)
            {
                var apiError = new ApiErrorDto("Get Pin Details by Contact Failed", ex);
                throw new HttpResponseException(apiError.HttpResponseMessage);
            }
        }