// <summary> /// Gets approx location based on the postal code. /// </summary> /// <param name="postcode"></param> /// <returns>The approx location/</returns> public async Task <DbGeometry> GetApproxLocation(string postcode) { using (loggingHelper.RMTraceManager.StartTrace("IntegrationService.GetApproxLocation")) { string methodName = typeof(DeliveryPointIntegrationService) + "." + nameof(GetApproxLocation); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); HttpResponseMessage result = await httpHandler.GetAsync(unitManagerDataWebAPIName + "postcode/approxlocation/" + postcode); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } // DbGeometry approxLocation = JsonConvert.DeserializeObject<DbGeometry>(result.Content.ReadAsStringAsync().Result); DBGeometryDTO locationObject = JsonConvert.DeserializeObject <DBGeometryDTO>(result.Content.ReadAsStringAsync().Result); DbGeometry approxLocation = locationObject.Geometry; loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(approxLocation); } }
public async Task <IActionResult> GetApproxLocation(string postcode) { if (postcode == null) { throw new ArgumentNullException(nameof(postcode)); } string methodName = typeof(UnitManagerController) + "." + nameof(GetApproxLocation); using (loggingHelper.RMTraceManager.StartTrace("WebService.GetApproxLocation")) { loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerControllerMethodEntryEventId); var location = await unitLocationBusinessService.GetApproxLocation(postcode, CurrentUserUnit); DBGeometryDTO geometryData = new DBGeometryDTO { Geometry = location }; loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerControllerMethodEntryEventId); return(Ok(geometryData)); } }