From 57368a3f98504798fbc7119bc59bac298855cae8 Mon Sep 17 00:00:00 2001 From: KKAYFISH Date: Thu, 30 Nov 2023 15:19:13 -0800 Subject: [PATCH] EMBCESSMOD-4753: Updated conflict detection to ignore spaces in postalcode --- .../Services/ProfilesConflictDetector.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/registrants/src/API/EMBC.Registrants.API/Services/ProfilesConflictDetector.cs b/registrants/src/API/EMBC.Registrants.API/Services/ProfilesConflictDetector.cs index e91e81868..b7c73da6a 100644 --- a/registrants/src/API/EMBC.Registrants.API/Services/ProfilesConflictDetector.cs +++ b/registrants/src/API/EMBC.Registrants.API/Services/ProfilesConflictDetector.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using EMBC.Registrants.API.Controllers; namespace EMBC.Registrants.API.Services @@ -39,7 +40,7 @@ private static bool AddressEquals(this Address address, Address other) => (address == null && other == null) || (address != null && address.AddressLine1.StringSafeEquals(other?.AddressLine1) && - address.PostalCode.StringSafeEquals(other?.PostalCode) && + address.PostalCode.RemoveWhitespace().StringSafeEquals(other?.PostalCode.RemoveWhitespace()) && address.StateProvince.StringSafeEquals(other?.StateProvince)); private static bool NameEquals(this PersonDetails personDetails, PersonDetails other) => @@ -52,5 +53,11 @@ private static bool DateofBirthEquals(this PersonDetails personDetails, PersonDe private static bool StringSafeEquals(this string s, string other) => string.Equals((s ?? string.Empty).Trim(), (other ?? string.Empty).Trim(), StringComparison.InvariantCultureIgnoreCase); + public static string RemoveWhitespace(this string input) + { + return new string(input.ToCharArray() + .Where(c => !char.IsWhiteSpace(c)) + .ToArray()); + } } }