Skip to content

Commit

Permalink
Merge pull request #1723 from bcgov/bc-services-login
Browse files Browse the repository at this point in the history
BC Services Login
  • Loading branch information
saikrishnametpalli-nttdata authored Mar 28, 2024
2 parents 92dbf1d + 772d2ab commit 7c425d5
Showing 1 changed file with 45 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Text;
using TrafficCourts.Citizen.Service.Features.CurrentUserInfo;
using TrafficCourts.Citizen.Service.Features.Disputes;
using TrafficCourts.Citizen.Service.Models.Disputes;
Expand Down Expand Up @@ -562,40 +563,63 @@ private static bool IsDisputeStatus(string value, DisputeStatus status)

private bool CompareNames(SubmitNoticeOfDispute message, UserInfo? user)
{
#if DEBUG
#if DEBUG
#warning Contact Name Comparisons with BC Services Cards have been disabled
return true;
return true;
#endif
bool result = true;

// if contact type is individual then match with disputant name otherwise match with contact names
if (message.ContactTypeCd == DisputeContactTypeCd.INDIVIDUAL)
string Combine(string? name1, string? name2, string? name3)
{
var givenNames = message.DisputantGivenName1
+ (message.DisputantGivenName2 != null ? (" " + message.DisputantGivenName2) : "")
+ (message.DisputantGivenName3 != null ? (" " + message.DisputantGivenName3) : "");
if (!message.DisputantSurname.Equals(user?.Surname, StringComparison.OrdinalIgnoreCase)
|| !(message.DisputantGivenName1.Equals(user?.GivenName, StringComparison.OrdinalIgnoreCase) || givenNames.Equals(user?.GivenNames, StringComparison.OrdinalIgnoreCase)))
StringBuilder buffer = new StringBuilder();
if (!string.IsNullOrEmpty(name1))
{
buffer.Append(name1.Trim());
}

if (!string.IsNullOrEmpty(name2))
{
result = false;
if (buffer.Length > 0)
{
buffer.Append(' ');
}
buffer.Append(name2.Trim());
}

if (!string.IsNullOrEmpty(name3))
{
if (buffer.Length > 0)
{
buffer.Append(' ');
}
buffer.Append(name3.Trim());
}
return buffer.ToString();
}
else if (message.ContactTypeCd == DisputeContactTypeCd.LAWYER || message.ContactTypeCd == DisputeContactTypeCd.OTHER)

bool DoesContain(string? a, string? b)
{
var givenNames = message.ContactGiven1Nm
+ (message.ContactGiven2Nm != null ? (" " + message.ContactGiven2Nm) : "")
+ (message.ContactGiven3Nm != null ? (" " + message.ContactGiven3Nm) : "");
if (!message.ContactSurnameNm.Equals(user?.Surname, StringComparison.OrdinalIgnoreCase)
|| !(message.ContactGiven1Nm.Equals(user?.GivenName, StringComparison.OrdinalIgnoreCase) || givenNames.Equals(user?.GivenNames, StringComparison.OrdinalIgnoreCase)))
if (!string.IsNullOrEmpty(a) && !string.IsNullOrEmpty(b))
{
result = false;
return a.Contains(b, StringComparison.OrdinalIgnoreCase);
}
else
{
return false;
}
}
else

// if contact type is individual then match with disputant name otherwise match with contact names
if (message.ContactTypeCd == DisputeContactTypeCd.INDIVIDUAL)
{
var givenNames = Combine(message.DisputantGivenName1, message.DisputantGivenName2, message.DisputantGivenName3);
return DoesContain(user?.GivenNames, givenNames) && DoesContain(user?.Surname, message.DisputantSurname);
}
else if (message.ContactTypeCd == DisputeContactTypeCd.LAWYER || message.ContactTypeCd == DisputeContactTypeCd.OTHER)
{
result = false;
var givenNames = Combine(message.ContactGiven1Nm, message.ContactGiven2Nm, message.ContactGiven3Nm);
return DoesContain(user?.GivenNames, givenNames) && DoesContain(user?.Surname, message.ContactSurnameNm);
}

return result;
return false;
}
}

0 comments on commit 7c425d5

Please sign in to comment.