/// <summary> /// This method updates delivery point location using UDPRN /// </summary> /// <param name="deliveryPointDTO">deliveryPointDTO as DTO</param> /// <returns>updated delivery point</returns> public async Task <int> UpdateDeliveryPointLocationOnUDPRN(DeliveryPointDTO deliveryPointDTO) { using (loggingHelper.RMTraceManager.StartTrace("Integration.UpdateDeliveryPointLocationOnUDPRN")) { string method = typeof(ThirdPartyAddressLocationIntegrationService) + "." + nameof(UpdateDeliveryPointLocationOnUDPRN); loggingHelper.LogMethodEntry(method, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationIntegrationServiceMethodEntryEventId); string methodName = ThirdPartyAddressLocationConstants.UpdateDeliveryPointLocationOnUDPRN; string serviceUrl = configurationHelper.ReadAppSettingsConfigurationValues(DeliveryPointManagerDataWebAPIName); string route = configurationHelper.ReadAppSettingsConfigurationValues(methodName); HttpResponseMessage result = await httpHandler.PostAsJsonAsync(serviceUrl + route, JsonConvert.SerializeObject(deliveryPointDTO, new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() })); if (!result.IsSuccessStatusCode) { // LOG ERROR WITH Statuscode var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } int status = JsonConvert.DeserializeObject <int>(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(method, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationIntegrationServiceMethodExitEventId); return(status); } }
/// <summary> /// Update Delivery Point by Id /// </summary> /// <param name="deliveryPointDTO">Delivery Point DTO</param> /// <returns>whether DP has been updated successfully</returns> public async Task <Guid> UpdateDeliveryPointById(DeliveryPointDTO deliveryPointDTO) { using (loggingHelper.RMTraceManager.StartTrace("Integration.UpdateDeliveryPointById")) { string method = typeof(ThirdPartyAddressLocationIntegrationService) + "." + nameof(UpdateDeliveryPointById); loggingHelper.LogMethodEntry(method, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationIntegrationServiceMethodEntryEventId); string methodName = MethodHelper.GetActualAsyncMethodName(); string serviceUrl = configurationHelper.ReadAppSettingsConfigurationValues(DeliveryPointManagerDataWebAPIName); string route = configurationHelper.ReadAppSettingsConfigurationValues(methodName); string serializedDeliveryPoint = JsonConvert.SerializeObject(deliveryPointDTO); HttpResponseMessage result = await httpHandler.PutAsJsonAsync(serviceUrl + route, serializedDeliveryPoint); if (!result.IsSuccessStatusCode) { // LOG ERROR WITH Statuscode var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } Guid deliveryPointID = JsonConvert.DeserializeObject <Guid>(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(method, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationIntegrationServiceMethodExitEventId); return(deliveryPointID); } }
public async Task <bool> UpdateDeliveryPointAccessLinkCreationStatus(DeliveryPointDTO deliveryPointDTO) { using (loggingHelper.RMTraceManager.StartTrace("Integration.UpdateDeliveryPointAccessLinkCreationStatus")) { string methodName = typeof(AccessLinkIntegrationService) + "." + nameof(UpdateDeliveryPointAccessLinkCreationStatus); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); var jsonSerializerSettings = new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var deliveryPointDTOJson = JsonConvert.SerializeObject(deliveryPointDTO, jsonSerializerSettings); HttpResponseMessage result = await httpHandler.PutAsJsonAsync(deliveryPointManagerDataWebAPIName + "deliverypoint/accesslinkstatus", deliveryPointDTOJson); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } var success = JsonConvert.DeserializeObject <bool>(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(success); } }
public async Task <IActionResult> GetDeliveryPointByUDPRNforBatch(int udprn) { try { using (loggingHelper.RMTraceManager.StartTrace("WebService.GetDeliveryPointByUDPRNforBatch")) { string methodName = typeof(DeliveryPointController) + "." + nameof(GetDeliveryPointByUDPRNforBatch); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); DeliveryPointDTO deliveryPointDTO = await businessService.GetDeliveryPointByUDPRNforBatch(udprn); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(Ok(deliveryPointDTO)); } } catch (AggregateException ae) { foreach (var exception in ae.InnerExceptions) { loggingHelper.Log(exception, TraceEventType.Error); } var realExceptions = ae.Flatten().InnerException; throw realExceptions; } }
/// <summary> /// Method to update the DP location based on UDPRN. /// </summary> /// <param name="addressLocationUSRPOSTDTO"></param> /// <param name="notificationType">Notification Type</param> private async Task UpdateDPLocation(AddressLocationUSRPOSTDTO addressLocationUSRPOSTDTO, Guid notificationType) { DbGeometry spatialLocationXY = GetSpatialLocation(addressLocationUSRPOSTDTO); PostalAddressDataDTO postalAddressDataDTO = await addressLocationDataService.GetPostalAddressData(addressLocationUSRPOSTDTO.UDPRN.Value); // If Delivery Point Exists for the given Postal Address if (postalAddressDataDTO != null && postalAddressDataDTO.DeliveryPoints != null && postalAddressDataDTO.DeliveryPoints.Count > 0 && spatialLocationXY != null) { DeliveryPointDTO deliveryPointDTO = await thirdPartyAddressLocationIntegrationService.GetDeliveryPointByPostalAddress(postalAddressDataDTO.ID); if (deliveryPointDTO != null && deliveryPointDTO.LocationXY != null) { double?toleranceDistance = spatialLocationXY.Distance(deliveryPointDTO.LocationXY); deliveryPointDTO.LocationXY = spatialLocationXY; // Update the location details for the delivery point await thirdPartyAddressLocationIntegrationService.UpdateDeliveryPointById(deliveryPointDTO); // Check Tolerance. Story: RFMO-279 CheckToleranceForLocation(toleranceDistance, false, notificationType, addressLocationUSRPOSTDTO.UDPRN.Value, postalAddressDataDTO); } } }
/// <summary> /// Calculte distance between two points /// </summary> /// <param name="deliveryPointDTO">deliveryPoint DTO</param> /// <param name="newPoint">newPoint as DbGeometry</param> /// <returns>distance as double</returns> private double?GetDeliveryPointDistance(DeliveryPointDTO deliveryPointDTO, DbGeometry newPoint) { using (loggingHelper.RMTraceManager.StartTrace("BusinessService.GetDeliveryPointDistance")) { string methodName = typeof(ThirdPartyAddressLocationBusinessService) + "." + nameof(GetDeliveryPointDistance); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.GetPostalAddressDetailsByIdPriority, LoggerTraceConstants.GetPostalAddressDetailsByIdBusinessMethodEntryEventId); double?distance = 0; if (deliveryPointDTO != null) { distance = deliveryPointDTO.LocationXY.Distance(newPoint); } loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.PostalAddressAPIPriority, LoggerTraceConstants.PostalAddressBusinessServiceMethodExitEventId); return(distance); } }
/// <summary> /// This method is used to fetch Delivery Point by udprn. /// </summary> /// <param name="udprn">udprn as int</param> /// <returns>DeliveryPointDTO</returns> public async Task <DeliveryPointDTO> GetDeliveryPointByUDPRNForThirdParty(int uDPRN) { using (loggingHelper.RMTraceManager.StartTrace("Integration.GetDeliveryPointByUDPRNForThirdParty")) { string method = typeof(ThirdPartyAddressLocationIntegrationService) + "." + nameof(GetDeliveryPointByUDPRNForThirdParty); loggingHelper.LogMethodEntry(method, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationIntegrationServiceMethodEntryEventId); string methodName = ThirdPartyAddressLocationConstants.GetDeliveryPointByUDPRNForThirdParty; string serviceUrl = configurationHelper.ReadAppSettingsConfigurationValues(DeliveryPointManagerDataWebAPIName); string route = configurationHelper.ReadAppSettingsConfigurationValues(methodName); HttpResponseMessage result = await httpHandler.GetAsync(string.Format(serviceUrl + route, uDPRN.ToString())); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } DeliveryPointDTO deliveryPointDTO = JsonConvert.DeserializeObject <DeliveryPointDTO>(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(method, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationIntegrationServiceMethodExitEventId); return(deliveryPointDTO); } }
/// <summary> /// Setup data /// </summary> protected override void OnSetup() { currentUserUnit = "Delivery Office"; mockDeliveryPointsDataService = CreateMock <IDeliveryPointsDataService>(); mockConfigurationDataService = CreateMock <IConfigurationHelper>(); mockLoggingDataService = CreateMock <ILoggingHelper>(); mockDeliveryPointIntegrationService = CreateMock <IDeliveryPointIntegrationService>(); var rmTraceManagerMock = new Mock <IRMTraceManager>(); rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>())); mockLoggingDataService.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object); SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory); List <DeliveryPointDTO> lstDeliveryPointDTO = new List <DeliveryPointDTO>(); List <RM.CommonLibrary.EntityFramework.Entities.DeliveryPoint> lstDeliveryPoint = new List <RM.CommonLibrary.EntityFramework.Entities.DeliveryPoint>(); List <PostalAddressDataDTO> lstPostalAddressDTO = new List <PostalAddressDataDTO>() { new PostalAddressDataDTO { BuildingName = "Bldg 1", BuildingNumber = 23, Postcode = "123" } }; deliveryPointDTO = new DeliveryPointDTO() { ID = Guid.NewGuid() }; postalAddressesDTO = new List <PostalAddressDTO>() { new PostalAddressDTO() { BuildingName = "bldg1", BuildingNumber = 1, SubBuildingName = "subbldg", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12") }, new PostalAddressDTO() { BuildingName = "bldg1", BuildingNumber = 1, SubBuildingName = "subbldg", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "Postcode", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), ID = Guid.Empty }, new PostalAddressDTO() { BuildingName = "bldg1", BuildingNumber = 1, SubBuildingName = "subbldg", OrganisationName = null, DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "Postcode", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), ID = Guid.Empty } }; addDeliveryPointDTO = new AddDeliveryPointDTO() { PostalAddressDTO = postalAddressesDTO[0], DeliveryPointDTO = deliveryPointDTO, RangeType = "Odds", DeliveryPointType = "Range", FromRange = 2, ToRange = 11, }; addDeliveryPointDTO1 = new AddDeliveryPointDTO() { PostalAddressDTO = postalAddressesDTO[1], DeliveryPointDTO = deliveryPointDTO }; deliveryPointModelDTO = new DeliveryPointModelDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), XCoordinate = 12, YCoordinate = 10, UDPRN = 123, Latitude = 1, Longitude = 2, RowVersion = BitConverter.GetBytes(1) }; actualDeliveryPointDataDto = new List <DeliveryPointDataDTO>() { new DeliveryPointDataDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), MailVolume = 5, PostalAddress = new PostalAddressDataDTO() { BuildingName = "bldg1", BuildingNumber = 1, SubBuildingName = "subbldg", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12") }, NetworkNode = new NetworkNodeDataDTO { ID = Guid.Empty, NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), Location = new LocationDataDTO() { Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700) } }, DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>() { new DeliveryPointStatusDataDTO { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") } } }, new DeliveryPointDataDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A17"), MailVolume = 2, PostalAddress = new PostalAddressDataDTO() { BuildingName = "bldg2", BuildingNumber = 1, SubBuildingName = "subbldg1", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") }, NetworkNode = new NetworkNodeDataDTO { ID = Guid.Empty, NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), Location = new LocationDataDTO() { Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700) } }, DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>() { new DeliveryPointStatusDataDTO { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") } } } }; actualDeliveryPointDTO = new DeliveryPointDataDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A17"), MailVolume = 2, PostalAddress = new PostalAddressDataDTO() { BuildingName = "bldg2", BuildingNumber = 1, SubBuildingName = "subbldg1", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") }, NetworkNode = new NetworkNodeDataDTO { ID = Guid.Empty, NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), Location = new LocationDataDTO() { Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700) } }, DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>() { new DeliveryPointStatusDataDTO { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") } } }; AddDeliveryPointDTO actualAddDeliveryPointDTO = new AddDeliveryPointDTO() { PostalAddressDTO = new PostalAddressDTO() { BuildingName = "bldg2", BuildingNumber = 1, SubBuildingName = "subbldg1", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") } }; var locationXy = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700); DbGeometry location = DbGeometry.PointFromText("POINT (488938 197021)", 27700); List <RM.CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO> referenceData = GetReferenceDataCategory(); double xLocation = 399545.5590911182; double yLocation = 649744.6394892789; routeDTO = new RouteDTO { RouteName = "Route-001", RouteNumber = "001" }; mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoints(It.IsAny <string>(), It.IsAny <Guid>(), It.IsAny <string>())).Returns(actualDeliveryPointDataDto); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoint(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDetailDeliveryPointByUDPRN(It.IsAny <int>())).Returns(actualAddDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsForBasicSearch(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsCount(It.IsAny <string>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto.Count); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsForAdvanceSearch(It.IsAny <string>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto); // GetDeliveryPointsForAdvanceSearch mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnUDPRN(It.IsAny <DeliveryPointDataDTO>())).Returns(Task.FromResult(1)); mockDeliveryPointsDataService.Setup(x => x.UpdatePAFIndicator(It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(true); mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateNybRecords(It.IsAny <PostalAddressDTO>())).Returns(Task.FromResult("ABC")); mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateAddressWithDeliveryPoints(It.IsAny <PostalAddressDTO>())).Returns(Task.FromResult(true)); mockDeliveryPointIntegrationService.Setup(x => x.CreateAddressForDeliveryPoint(It.IsAny <AddDeliveryPointDTO>())).ReturnsAsync(new CreateDeliveryPointModelDTO() { ID = Guid.NewGuid(), IsAddressLocationAvailable = true, Message = "Delivery Point Created", XCoordinate = xLocation, YCoordinate = yLocation }); mockDeliveryPointIntegrationService.Setup(x => x.GetReferenceDataSimpleLists(It.IsAny <List <string> >())).ReturnsAsync(referenceData); mockDeliveryPointIntegrationService.Setup(x => x.GetApproxLocation(It.IsAny <string>())).ReturnsAsync(location); mockDeliveryPointsDataService.Setup(x => x.InsertDeliveryPoint(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(Guid.NewGuid()); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointRowVersion(It.IsAny <Guid>())).Returns(BitConverter.GetBytes(1)); mockDeliveryPointIntegrationService.Setup(x => x.MapRouteForDeliveryPoint(It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(true); mockDeliveryPointIntegrationService.Setup(x => x.GetReferenceDataGuId(It.IsAny <string>(), It.IsAny <string>())).Returns(Guid.NewGuid()); mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnID(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(Guid.NewGuid()); mockDeliveryPointIntegrationService.Setup(x => x.CreateAddressForDeliveryPointForRange(It.IsAny <List <PostalAddressDTO> >())).ReturnsAsync(new List <CreateDeliveryPointModelDTO> { new CreateDeliveryPointModelDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12"), IsAddressLocationAvailable = true, Message = "Delivery Point Created", XCoordinate = xLocation, YCoordinate = yLocation } }); mockDeliveryPointIntegrationService.Setup(x => x.GetRouteForDeliveryPoint(It.IsAny <Guid>())).ReturnsAsync(routeDTO); mockDeliveryPointsDataService.Setup(x => x.DeliveryPointExists(It.IsAny <int>())).ReturnsAsync(true); mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnUDPRN(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(5); mockDeliveryPointIntegrationService.Setup(x => x.CreateAccessLink(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(true); mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateNybRecords(It.IsAny <PostalAddressDTO>())).ReturnsAsync("123"); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByUDPRN(It.IsAny <int>())).ReturnsAsync(actualDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByPostalAddress(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsCrossingOperationalObject(It.IsAny <string>(), It.IsAny <DbGeometry>())).Returns(actualDeliveryPointDataDto); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoint(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByPostalAddressWithLocation(It.IsAny <Guid>())).ReturnsAsync(actualDeliveryPointDTO); testCandidate = new DeliveryPointBusinessService(mockDeliveryPointsDataService.Object, mockLoggingDataService.Object, mockConfigurationDataService.Object, mockDeliveryPointIntegrationService.Object); }
public async Task Test_GetDeliveryPointByPostalAddressWithLocation_PositiveScenario() { DeliveryPointDTO expectedresult = await testCandidate.GetDeliveryPointByPostalAddressWithLocation(addressGuid); Assert.IsNotNull(expectedresult); }
/// <summary> /// Setup for Nunit Tests. /// </summary> protected override void OnSetup() { accessLinkManualCreateModelDTO = new AccessLinkManualCreateModelDTO { AccessLinkLine = "[[512455.33999999985,107127.7899999991],[512454.8208646417,107129.43228437999],[512474,107139]]", BoundingBoxCoordinates = "511684.44432227453,106504.23168359262,513419.32779204147,107103.43288199503", NetworkLinkGUID = "c55712fe-ce92-4386-a0a5-e9a158b15441", OperationalObjectGUID = "ffc86397-fbb5-4caf-a070-aca8d723de57", Workloadlength = 40, NetworkIntersectionPoint = "[512455.33999999985,107127.7899999991]", OperationalObjectPoint = "[512455.33999999985,107127.7899999991]" }; deliveryPointDTO = new DeliveryPointDTO { LocationXY = DbGeometry.PointFromText("POINT (488938 197021)", 27700), Latitude = (decimal)50.83133590, Longitude = (decimal) - 0.40071150, Positioned = true, UDPRN = 2364534, PostalAddress = new RM.CommonLibrary.EntityFramework.DTO.PostalAddressDTO { Thoroughfare = "Salvington Gardens" }, DeliveryPointUseIndicator_GUID = Guid.Parse("178EDCAD-9431-E711-83EC-28D244AEF9ED") }; accessLinkDTO = new List <AccessLinkDTO>() { new AccessLinkDTO() { ID = Guid.Parse("3981AD3B-D253-4BD9-AB82-000094D8EE67"), OperationalObjectPoint = DbGeometry.PointFromText("POINT (488938 197021)", 27700), NetworkIntersectionPoint = DbGeometry.PointFromText("POINT (488929.9088937093 197036.37310195228)", 27700), AccessLinkLine = DbGeometry.LineFromText("LINESTRING (488938 197021, 488929.9088937093 197036.37310195228)", 27700), NetworkLink_GUID = Guid.Parse("4DBA7B39-D23E-493A-9B8F-B94D181A082F") } }; networkLink = new NetworkLinkDTO { Id = Guid.Parse("4DBA7B39-D23E-493A-9B8F-B94D181A082F"), TOID = "osgb4000000023358315", NetworkLinkType_GUID = Guid.Parse("09CE57B1-AF13-4F8E-B4AF-1DE35B4A68A8"), LinkGeometry = DbGeometry.LineFromText("LINESTRING (488952 197048, 488895 197018, 488888 197014, 488880 197008)", 27700) }; SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory); SqlGeometry networkIntersectionPoint = SqlGeometry.Null; List <SqlGeometry> lstnetworkIntersectionPoint = new List <SqlGeometry>(); try { networkIntersectionPoint = accessLinkDTO[0].OperationalObjectPoint.ToSqlGeometry().ShortestLineTo(networkLink.LinkGeometry.ToSqlGeometry()).STEndPoint(); lstnetworkIntersectionPoint.Add(networkIntersectionPoint); } catch (Exception) { } Tuple <NetworkLinkDTO, SqlGeometry> tuple = new Tuple <NetworkLinkDTO, SqlGeometry>(networkLink, networkIntersectionPoint); List <Tuple <NetworkLinkDTO, SqlGeometry> > tuple1 = new List <Tuple <NetworkLinkDTO, SqlGeometry> > { new Tuple <NetworkLinkDTO, SqlGeometry>(networkLink, networkIntersectionPoint) }; List <ReferenceDataCategoryDTO> refDataCategotyDTO = new List <ReferenceDataCategoryDTO>() { new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.AccessLinkType, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = null, ReferenceDataValue = ReferenceDataValues.AccessLinkTypeDefault, ID = Guid.Parse("4DBA7B39-D23E-493A-9B8F-B94D181A082F") }, new ReferenceDataDTO() { ReferenceDataName = null, ReferenceDataValue = ReferenceDataValues.UserDefined, ID = Guid.Parse("DA8F1A91-2E2B-4EEF-9A81-9B18A917CBF1") } } }, new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.AccessLinkDirection, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = null, ReferenceDataValue = ReferenceDataValues.AccessLinkDirectionBoth, ID = Guid.Parse("5DBA7B39-D23E-493A-9B8F-B94D181A082F") } } }, new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.AccessLinkStatus, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = null, ReferenceDataValue = ReferenceDataValues.AccessLinkStatusLive, ID = Guid.Parse("6DBA7B39-D23E-493A-9B8F-B94D181A082F") }, new ReferenceDataDTO() { ReferenceDataName = null, ReferenceDataValue = ReferenceDataValues.AccessLinkStatusDraftPendingApproval, ID = Guid.Parse("7DBA7B39-D23E-493A-9B8F-B94D181A082F") }, new ReferenceDataDTO() { ReferenceDataName = null, ReferenceDataValue = ReferenceDataValues.AccessLinkStatusDraftPendingReview, ID = Guid.Parse("7B90B2F9-F62F-E711-8735-28D244AEF9ED") } } }, new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.OperationalObjectType, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = ReferenceDataValues.OperationalObjectTypeDP, ReferenceDataValue = ReferenceDataValues.OperationalObjectTypeDP, ID = Guid.Parse("415c9129-0615-457e-98b7-3a60436320c5") } } }, new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.AccessLinkParameters, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = ReferenceDataValues.AccessLinkSameRoadMaxDistance, ReferenceDataValue = "25", ID = Guid.Parse("9DBA7B39-D23E-493A-9B8F-B94D181A082F") }, new ReferenceDataDTO() { ReferenceDataName = ReferenceDataValues.AccessLinkDiffRoadMaxDistance, ReferenceDataValue = "1", ID = Guid.Parse("3DBA7B39-D23E-493A-9B8F-B94D181A081F") }, } }, new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.NetworkLinkType, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = ReferenceDataValues.AccessLinkDiffRoadMaxDistance, ReferenceDataValue = "Road Link", ID = Guid.Parse("09ce57b1-af13-4f8e-b4af-1de35b4a68a8") } } }, new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.AccessLinkParameters, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = "Local Road", ReferenceDataValue = "1", ID = Guid.Parse("4DBA7B35-D23E-493A-9B8F-B94D181A082F") } } }, new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.DeliveryPointUseIndicator, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = "DeliveryPointUseIndicator", ReferenceDataValue = "Residential", ID = Guid.Parse("178edcad-9431-e711-83ec-28d244aef9ed") } } }, }; loggingHelperMock = CreateMock <ILoggingHelper>(); // Setup Methods. mockaccessLinkDataService = new Mock <IAccessLinkDataService>(); mockAccessLinkIntegrationService = CreateMock <IAccessLinkIntegrationService>(); mockaccessLinkDataService.Setup(x => x.GetAccessLinks(It.IsAny <string>(), It.IsAny <Guid>())).Returns(It.IsAny <List <AccessLinkDataDTO> >); mockaccessLinkDataService.Setup(x => x.GetAccessLinksCrossingOperationalObject(It.IsAny <string>(), It.IsAny <DbGeometry>())).Returns(default(bool)); mockaccessLinkDataService.Setup(x => x.DeleteAccessLink(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(true); mockAccessLinkIntegrationService.Setup(x => x.GetReferenceDataNameValuePairs(It.IsAny <List <string> >())).ReturnsAsync(new List <ReferenceDataCategoryDTO>() { }); mockAccessLinkIntegrationService.Setup(x => x.GetReferenceDataSimpleLists(It.IsAny <List <string> >())).ReturnsAsync(refDataCategotyDTO); mockAccessLinkIntegrationService.Setup(x => x.GetDeliveryPoint(It.IsAny <Guid>())).ReturnsAsync(deliveryPointDTO); mockAccessLinkIntegrationService.Setup(x => x.GetNearestNamedRoad(It.IsAny <DbGeometry>(), It.IsAny <string>())).ReturnsAsync(tuple); mockAccessLinkIntegrationService.Setup(x => x.GetNearestSegment(It.IsAny <DbGeometry>())).ReturnsAsync(tuple1); mockAccessLinkIntegrationService.Setup(x => x.GetOSRoadLink(It.IsAny <string>())).ReturnsAsync("Local Road"); mockAccessLinkIntegrationService.Setup(x => x.GetCrossingNetworkLinks(It.IsAny <string>(), It.IsAny <DbGeometry>())).ReturnsAsync(new List <NetworkLinkDTO>() { }); mockAccessLinkIntegrationService.Setup(x => x.GetDeliveryPointsCrossingOperationalObject(It.IsAny <string>(), It.IsAny <DbGeometry>())).ReturnsAsync(new List <DeliveryPointDTO>() { }); mockAccessLinkIntegrationService.Setup(x => x.GetNetworkLink(It.IsAny <Guid>())).ReturnsAsync(networkLink); mockaccessLinkDataService.Setup(x => x.CreateAccessLink(It.IsAny <AccessLinkDataDTO>())).Returns(true); var rmTraceManagerMock = new Mock <IRMTraceManager>(); rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>())); loggingHelperMock.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object); testCandidate = new AccessLinkBusinessService(mockaccessLinkDataService.Object, loggingHelperMock.Object, mockAccessLinkIntegrationService.Object); }
// TODO : Add method when ready // To be implemented in parallel /// <summary> /// Method to save the list of USR data into the database. /// </summary> /// <param name="addressLocationUsrpostdtos">List of Address Locations</param> /// <returns>Task</returns> public async Task SaveUSRDetails(List <AddressLocationUSRPOSTDTO> addressLocationUsrpostdtos) { int fileUdprn; string addressLocationChangeType = string.Empty; if (addressLocationUsrpostdtos == null) { throw new ArgumentNullException(nameof(addressLocationUsrpostdtos)); } using (loggingHelper.RMTraceManager.StartTrace("Business.SaveUSRDetails")) { string methodName = typeof(ThirdPartyAddressLocationBusinessService) + "." + nameof(SaveUSRDetails); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodEntryEventId); List <string> categoryNamesSimpleLists = new List <string> { ThirdPartyAddressLocationConstants.TASKNOTIFICATION, ThirdPartyAddressLocationConstants.NETWORKLINKDATAPROVIDER, ThirdPartyAddressLocationConstants.DeliveryPointUseIndicator, ThirdPartyAddressLocationConstants.APPROXLOCATION, ReferenceDataCategoryNames.DeliveryPointOperationalStatus, ReferenceDataCategoryNames.NetworkNodeType }; // Get all the reference data Guids required for the below Guid tasktypeId = GetReferenceData(categoryNamesSimpleLists, ThirdPartyAddressLocationConstants.TASKNOTIFICATION, ThirdPartyAddressLocationConstants.TASKACTION); Guid locationProviderId = GetReferenceData(categoryNamesSimpleLists, ThirdPartyAddressLocationConstants.NETWORKLINKDATAPROVIDER, ThirdPartyAddressLocationConstants.EXTERNAL); Guid operationalStatusGUIDLive = GetReferenceData(categoryNamesSimpleLists, ReferenceDataCategoryNames.DeliveryPointOperationalStatus, ThirdPartyAddressLocationConstants.OperationalStatusGUIDLive, true); Guid networkNodeTypeRMGServiceNode = GetReferenceData(categoryNamesSimpleLists, ReferenceDataCategoryNames.NetworkNodeType, ThirdPartyAddressLocationConstants.NetworkNodeTypeRMGServiceNode, true); Guid approxLocation = GetReferenceData(categoryNamesSimpleLists, ReferenceDataCategoryNames.DeliveryPointOperationalStatus, ThirdPartyAddressLocationConstants.APPROXLOCATION, true); Guid notificationTypeId_GUID = await thirdPartyAddressLocationIntegrationService.GetReferenceDataId(ThirdPartyAddressLocationConstants.USRCATEGORY, ThirdPartyAddressLocationConstants.USRREFERENCEDATANAME); foreach (AddressLocationUSRPOSTDTO addressLocationUSRPOSTDTO in addressLocationUsrpostdtos) { // Get the udprn id for each USR record. fileUdprn = (int)addressLocationUSRPOSTDTO.UDPRN; addressLocationChangeType = addressLocationUSRPOSTDTO.ChangeType; // To save new location if (addressLocationChangeType.Equals(ThirdPartyAddressLocationConstants.INSERT)) { if (!await addressLocationDataService.AddressLocationExists(fileUdprn)) { DbGeometry spatialLocationXY = GetSpatialLocation(addressLocationUSRPOSTDTO); AddressLocationDataDTO newAddressLocationDTO = new AddressLocationDataDTO() { ID = Guid.NewGuid(), UDPRN = (int)addressLocationUSRPOSTDTO.UDPRN, LocationXY = spatialLocationXY, Lattitude = (decimal)addressLocationUSRPOSTDTO.Latitude, Longitude = (decimal)addressLocationUSRPOSTDTO.Longitude }; // Save the address location data record to the database. await addressLocationDataService.SaveNewAddressLocation(newAddressLocationDTO); PostalAddressDataDTO postalAddressDataDTO = await addressLocationDataService.GetPostalAddressData((int)fileUdprn); // Check if the delivery point exists if (postalAddressDataDTO.DeliveryPoints != null && postalAddressDataDTO.DeliveryPoints.Count > 0) { DeliveryPointDTO deliveryPointDTO = await thirdPartyAddressLocationIntegrationService.GetDeliveryPointByPostalAddress(postalAddressDataDTO.ID); // Check if the existing delivery point has an approx location. if (deliveryPointDTO.OperationalStatus_GUID == approxLocation) { deliveryPointDTO.LocationXY = spatialLocationXY; deliveryPointDTO.LocationProvider_GUID = locationProviderId; deliveryPointDTO.UDPRN = fileUdprn; deliveryPointDTO.OperationalStatus_GUID = operationalStatusGUIDLive; deliveryPointDTO.NetworkNodeType_GUID = networkNodeTypeRMGServiceNode; // Update the location details for the delivery point await thirdPartyAddressLocationIntegrationService.UpdateDeliveryPointById(deliveryPointDTO); // Check if a notification exists for the UDPRN. if (await addressLocationDataService.CheckIfNotificationExists(fileUdprn, ThirdPartyAddressLocationConstants.TASKPAFACTION)) { // update the notification if it exists. await thirdPartyAddressLocationIntegrationService.UpdateNotificationByUDPRN(fileUdprn, ThirdPartyAddressLocationConstants.TASKPAFACTION, ThirdPartyAddressLocationConstants.NOTIFICATIONCLOSED); } } else { // Calculates the straight line distance between the existing delivery // point and the new delivery point. var straightLineDistance = GetDeliveryPointDistance(deliveryPointDTO, spatialLocationXY); // Check if the new point is within the tolerance limit if (straightLineDistance <= ThirdPartyAddressLocationConstants.TOLERANCEDISTANCEINMETERS) { deliveryPointDTO.LocationXY = spatialLocationXY; deliveryPointDTO.LocationProvider_GUID = locationProviderId; deliveryPointDTO.UDPRN = fileUdprn; deliveryPointDTO.OperationalStatus_GUID = operationalStatusGUIDLive; deliveryPointDTO.NetworkNodeType_GUID = networkNodeTypeRMGServiceNode; // Update the delivery point location directly in case it is within // the tolerance limits. await thirdPartyAddressLocationIntegrationService.UpdateDeliveryPointById(deliveryPointDTO); // Check if the notification exists for the given UDPRN. if (await addressLocationDataService.CheckIfNotificationExists(fileUdprn, ThirdPartyAddressLocationConstants.TASKPAFACTION)) { // update the notification if it exists. await thirdPartyAddressLocationIntegrationService.UpdateNotificationByUDPRN(fileUdprn, ThirdPartyAddressLocationConstants.TASKPAFACTION, ThirdPartyAddressLocationConstants.NOTIFICATIONCLOSED); } } else { // Get the Postcode Sector by UDPRN PostCodeSectorDTO postCodeSectorDTO = await thirdPartyAddressLocationIntegrationService.GetPostCodeSectorByUDPRN(fileUdprn); PostalAddressDataDTO postalAddressDTO = await addressLocationDataService.GetPostalAddressData(fileUdprn); NotificationDTO notificationDO = new NotificationDTO { ID = Guid.NewGuid(), NotificationType_GUID = notificationTypeId_GUID, NotificationDueDate = DateTime.UtcNow.AddHours(ThirdPartyAddressLocationConstants.NOTIFICATIONDUE), NotificationSource = ThirdPartyAddressLocationConstants.USRNOTIFICATIONSOURCE, Notification_Heading = ThirdPartyAddressLocationConstants.USRACTION, Notification_Message = AddressFields(postalAddressDTO), PostcodeDistrict = (postCodeSectorDTO == null || postCodeSectorDTO.District == null) ? string.Empty : postCodeSectorDTO.District, PostcodeSector = (postCodeSectorDTO == null || postCodeSectorDTO.Sector == null) ? string.Empty : postCodeSectorDTO.Sector, NotificationActionLink = string.Format(ThirdPartyAddressLocationConstants.USRNOTIFICATIONLINK, fileUdprn) }; // Insert the new notification. await thirdPartyAddressLocationIntegrationService.AddNewNotification(notificationDO); } } } } } // To update existing location else if (addressLocationChangeType.Equals(ThirdPartyAddressLocationConstants.UPDATE)) { // Match to Location on UDPRN (update Location) if (await addressLocationDataService.AddressLocationExists(fileUdprn)) { // Update the Address location. await UpdateAddressLocationByUDPRN(addressLocationUSRPOSTDTO); // Update the DP location. Story: RFMO-276 await UpdateDPLocation(addressLocationUSRPOSTDTO, notificationTypeId_GUID); } // No Match to Location on UDPRN - Log Error else { loggingHelper.Log(string.Format(ThirdPartyAddressLocationConstants.NoMatchToAddressOnUDPRN, fileUdprn), TraceEventType.Error); } } // To delete existing location else if (addressLocationChangeType.Equals(ThirdPartyAddressLocationConstants.DELETE)) { await DeleteUSRDetails(addressLocationUSRPOSTDTO); } } loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodExitEventId); } }
/// <summary> /// Method to delete the list of Third Party Address Location data into the database. /// </summary> /// <param name="addressLocationUsrpostdtos">List of Address Locations</param> /// <returns>Task</returns> public async Task DeleteUSRDetails(AddressLocationUSRPOSTDTO addressLocationUsrpostdtos) { int fileUdprn; using (loggingHelper.RMTraceManager.StartTrace("Business.DeleteUSRDetails")) { string methodName = typeof(ThirdPartyAddressLocationBusinessService) + "." + nameof(DeleteUSRDetails); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodEntryEventId); List <string> categoryNamesSimpleLists = new List <string> { ThirdPartyAddressLocationConstants.TASKNOTIFICATION, ThirdPartyAddressLocationConstants.NETWORKLINKDATAPROVIDER, ThirdPartyAddressLocationConstants.DeliveryPointUseIndicator, ThirdPartyAddressLocationConstants.APPROXLOCATION, ReferenceDataCategoryNames.DeliveryPointOperationalStatus, ReferenceDataCategoryNames.NetworkNodeType }; // Get all the reference data Guids required for the below Guid locationProviderInternalId = GetReferenceData(categoryNamesSimpleLists, ThirdPartyAddressLocationConstants.NETWORKLINKDATAPROVIDER, ThirdPartyAddressLocationConstants.INTERNAL); Guid notificationTypeId_GUID = await thirdPartyAddressLocationIntegrationService.GetReferenceDataId(ThirdPartyAddressLocationConstants.USRCATEGORY, ThirdPartyAddressLocationConstants.USRREFERENCEDATANAME); // Get the udprn id for each USR record. fileUdprn = (int)addressLocationUsrpostdtos.UDPRN; var addressLocation = addressLocationDataService.GetAddressLocationByUDPRN(fileUdprn).Result; if (addressLocation != null) { // Delete the address location data record to the database. await addressLocationDataService.DeleteAddressLocation(addressLocation); PostalAddressDataDTO postalAddressDataDTO = await addressLocationDataService.GetPostalAddressData((int)fileUdprn); // Check if the delivery point exists if (postalAddressDataDTO.DeliveryPoints != null && postalAddressDataDTO.DeliveryPoints.Count > 0) { DeliveryPointDTO deliveryPointDTO = await thirdPartyAddressLocationIntegrationService.GetDeliveryPointByPostalAddress(postalAddressDataDTO.ID); deliveryPointDTO.LocationProvider_GUID = locationProviderInternalId; // Update the location provider for the delivery point await thirdPartyAddressLocationIntegrationService.UpdateDeliveryPointById(deliveryPointDTO); // Get the Postcode Sector by UDPRN PostCodeSectorDTO postCodeSectorDTO = await thirdPartyAddressLocationIntegrationService.GetPostCodeSectorByUDPRN(fileUdprn); PostalAddressDataDTO postalAddressDTO = await addressLocationDataService.GetPostalAddressData(fileUdprn); NotificationDTO notificationDO = new NotificationDTO { ID = Guid.NewGuid(), NotificationType_GUID = notificationTypeId_GUID, NotificationDueDate = DateTime.UtcNow.AddHours(ThirdPartyAddressLocationConstants.NOTIFICATIONDUE), NotificationSource = ThirdPartyAddressLocationConstants.USRNOTIFICATIONSOURCE, Notification_Heading = ThirdPartyAddressLocationConstants.USRDELETEACTION, Notification_Message = Notification_Body(postalAddressDTO), PostcodeDistrict = (postCodeSectorDTO == null || postCodeSectorDTO.District == null) ? string.Empty : postCodeSectorDTO.District, NotificationActionLink = string.Format(ThirdPartyAddressLocationConstants.USRNOTIFICATIONLINK, fileUdprn) }; // Insert the new notification. await thirdPartyAddressLocationIntegrationService.AddNewNotification(notificationDO); } } else { // Log error loggingHelper.Log(string.Format(ThirdPartyAddressLocationConstants.USRERRORLOGMESSAGE, ThirdPartyAddressLocationConstants.ErrorMessageForAddressTypeUSRNotFound, fileUdprn, null, FileType.Usr, DateTime.UtcNow), TraceEventType.Error); } loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.ThirdPartyAddressLocationAPIPriority, LoggerTraceConstants.ThirdPartyAddressLocationDataServiceMethodExitEventId); } }