public void MapToCustomer_ShouldMapSocialContacts() { // Arrange var baseOrg = new FWTOrganisation { SocialContacts = new [] { new FWTSocialContact { SocialID = "id 1", SocialChannel = "channel 1" }, new FWTSocialContact { SocialID = "id 2", SocialChannel = "channel 2" } } }; // Act var mappedOrg = baseOrg.Map(); // Assert Assert.Equal("id 1", mappedOrg.SocialContacts[0].Value); Assert.Equal("channel 1", mappedOrg.SocialContacts[0].Type); Assert.Equal("id 2", mappedOrg.SocialContacts[1].Value); Assert.Equal("channel 2", mappedOrg.SocialContacts[1].Type); }
public int Calculate(FWTOrganisation organisationObject, StockportGovUK.NetStandard.Models.Verint.Organisation organisation) { if (organisation.Name != null && organisationObject.Name.Any(x => organisation.Name.Trim().ToLower() == x.FullName.Trim().ToLower())) { return(2); } return(0); }
public int Calculate(FWTOrganisation organisationObject, StockportGovUK.NetStandard.Models.Verint.Organisation organisation) { if (!string.IsNullOrEmpty(organisation.Telephone) && organisationObject.ContactPhones != null) { if (organisationObject.ContactPhones.Any(x => x.Number.Replace(" ", string.Empty).Replace("-", string.Empty).Trim() == organisation.Telephone.Replace(" ", string.Empty).Replace("-", string.Empty).Trim())) { return(1); } } return(0); }
public int Calculate(FWTOrganisation organisationObject, StockportGovUK.NetStandard.Models.Verint.Organisation organisation) { if (organisationObject.ContactEmails == null || organisationObject.ContactEmails.Length == 0 || string.IsNullOrEmpty(organisation.Email)) { return(0); } if (organisationObject.ContactEmails.Any(x => x.EmailAddress == organisation.Email)) { return(1); } return(0); }
public static Organisation Map(this FWTOrganisation organisation) { // _logger.LogDebug($"FwtCaseAssociatedOrganisationToOrganisation.Map Start"); var mappedOrganisation = new Organisation(); if (organisation.BriefDetails != null && organisation.BriefDetails.ObjectID.ObjectReference.Any()) { mappedOrganisation.Reference = organisation.BriefDetails.ObjectID.ObjectReference[0]; } if (organisation.SocialContacts != null && organisation.SocialContacts.Any()) { mappedOrganisation.SocialContacts = new SocialContact[organisation.SocialContacts.Length]; for (int i = 0; i < organisation.SocialContacts.Length; i++) { mappedOrganisation.SocialContacts[i] = new SocialContact { Value = organisation.SocialContacts[i].SocialID, Type = organisation.SocialContacts[i].SocialChannel }; } } if (organisation.ContactPostals != null && organisation.ContactPostals.Any()) { mappedOrganisation.Address = organisation.ContactPostals.OrderByDescending(_ => _.Preferred).FirstOrDefault().Map(); } if (organisation.Name?[0].FullName != null) { mappedOrganisation.Name = organisation.Name[0].FullName; } if (organisation.ContactEmails != null && organisation.ContactEmails.Any()) { mappedOrganisation.Email = organisation.ContactEmails.OrderByDescending(_ => _.Preferred).FirstOrDefault().EmailAddress; } if (organisation.ContactPhones != null && organisation.ContactPhones.Any()) { mappedOrganisation.Telephone = organisation.ContactPhones.OrderByDescending(_ => _.Preferred).FirstOrDefault().Number; } return(mappedOrganisation); }
public int Calculate(FWTOrganisation organisationObject, StockportGovUK.NetStandard.Models.Verint.Organisation organisation) { if (organisation.Address == null || organisationObject.ContactPostals == null || !string.IsNullOrEmpty(organisation.Address.UPRN)) { _logger.LogDebug($"AddressWeighting.Calculate - No contact postals or address null or uprn is not empty - Returning 0 - {organisation.Name}"); return(0); } var hasMatchingPostcode = false; var hasMatchingNumber = false; // This is effectively the same as a UPRN match (i.e. House Number and Postcode must match to be given weight) if (!string.IsNullOrEmpty(organisation.Address.Postcode) && organisationObject.ContactPostals.Any(x => !string.IsNullOrEmpty(x.Postcode) && string.Equals(x.Postcode.Trim().Replace(" ", string.Empty), organisation.Address.Postcode.Trim().Replace(" ", string.Empty), StringComparison.CurrentCultureIgnoreCase))) { _logger.LogDebug($"AddressWeighting.Calculate - IS matching postcode {organisation.Address.Postcode}, {organisation.Name}"); hasMatchingPostcode = true; } else { _logger.LogDebug($"AddressWeighting.Calculate - NON matching postcode {organisation.Address.Postcode}, {organisation.Name}"); } // if (!string.IsNullOrEmpty(organisation.Address.Number) && // organisationObject.ContactPostals.Any(x => !string.IsNullOrEmpty(x.AddressNumber) && // string.Equals(x.AddressNumber.Trim(), organisation.Address.Number.ToString(), StringComparison.CurrentCultureIgnoreCase))) // { // _logger.LogDebug($"AddressWeighting.Calculate - IS matching number {organisation.Address.Number}, {organisation.Name}"); // hasMatchingNumber = true; // } // else{ // _logger.LogDebug($"AddressWeighting.Calculate - NON matching number {organisation.Address.Number}, {organisation.Name}"); // } if (hasMatchingPostcode) { _logger.LogDebug($"AddressWeighting.Calculate - IS Matching address (postcode, number) - Returning 1 - {organisation.Name}"); return(1); } _logger.LogDebug($"AddressWeighting.Calculate - NON Matching address (postcode, number) - Returning 0 - {organisation.Name}"); return(0); }
public static FWTOrganisation Map(this Organisation organisation) { var fwtOrganisation = new FWTOrganisation() { Name = new [] { new FWTOrganisationName { FullName = organisation.Name.Trim(), Preferred = true } } }; if (organisation.Address != null) { fwtOrganisation.ContactPostals = new[] { organisation.Address.Map() }; } if (!string.IsNullOrEmpty(organisation.Telephone)) { fwtOrganisation.ContactPhones = new[] { new FWTContactPhone { Number = organisation.Telephone?.Trim(), Preferred = true } }; } if (!string.IsNullOrEmpty(organisation.Email)) { fwtOrganisation.ContactEmails = new[] { new FWTContactEmail { EmailAddress = organisation.Email?.Trim(), Preferred = true } }; } return(fwtOrganisation); }
private async Task <FWTObjectID> GetBestMatchingOrganisationAsync(FWTObjectBriefDetails[] searchResults, StockportGovUK.NetStandard.Models.Verint.Organisation organisation) { FWTOrganisation bestMatch = null; FWTObjectID bestMatchingObjectID = null; var bestMatchScore = 0; var tasks = new List <Task <retrieveOrganisationResponse> >(); foreach (var result in searchResults) { tasks.Add(Task.Run(async() => { _logger.LogDebug($"OrganisationService.GetBestMatchingOrganisationAsync - Get core Orgnisation Record : { result.ObjectID }"); return(await _verintConnection.retrieveOrganisationAsync(result.ObjectID)); })); } var results = await Task.WhenAll(tasks); results.ToList().ForEach((result) => { var orgnisationResult = result.FWTOrganisation; var score = 0; _organisationWeightings.ToList().ForEach(_ => score += _.Calculate(orgnisationResult, organisation)); _logger.LogDebug($"OrganisationService.GetBestMatchingOrganisationAsync - Organisation: { orgnisationResult.Name } Score: { score }"); if (score > bestMatchScore) { bestMatchScore = score; bestMatch = orgnisationResult; } }); if (bestMatch != null && bestMatchScore >= 3) { _logger.LogDebug($"OrganisationService.GetBestMatchingOrganisation Match Found - Organisation: {bestMatch.Name} Score: {bestMatchScore}"); // await UpdateIndividual(bestMatch, customer); bestMatchingObjectID = bestMatch.BriefDetails.ObjectID; } _logger.LogDebug($"OrganisationService.GetBestMatchingOrganisation Match Not Found"); return(bestMatchingObjectID); }
public int Calculate(FWTOrganisation organisationObject, StockportGovUK.NetStandard.Models.Verint.Organisation organisation) { if (organisation.Address == null || organisationObject.ContactPostals == null) { return(0); } if (string.IsNullOrEmpty(organisation.Address.UPRN)) { return(0); } if (organisationObject.ContactPostals.Any(x => x.UPRN == organisation.Address.UPRN.Trim())) { return(1); } return(0); }
public void MapToCustomer_ShouldMapName() { // Arrange var baseOrg = new FWTOrganisation { Name = new [] { new FWTOrganisationName { FullName = "Organisation name" } } }; // Act var mappedOrg = baseOrg.Map(); // Assert Assert.Equal("Organisation name", mappedOrg.Name); }
public void MapToCustomer_ShouldMapContactEmails() { // Arrange var baseOrg = new FWTOrganisation { ContactEmails = new[] { new FWTContactEmail { EmailAddress = "test email 1" }, new FWTContactEmail { EmailAddress = "test email 2" } } }; // Act var mappedOrg = baseOrg.Map(); // Assert Assert.Equal("test email 1", mappedOrg.Email); }