first commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Landmark.OLA.Application.Controllers;
|
||||
using Landmark.OLA.Models.Core;
|
||||
|
||||
namespace Landmark.OLA.Application.Services
|
||||
{
|
||||
public class CoreAccessService
|
||||
{
|
||||
public CoreMemberOwner FindMatchingOwner(OnlineIdentityFormData document, List<CoreMemberOwner> owners)
|
||||
{
|
||||
if (owners != null && owners.Count != 0 && document != null)
|
||||
{
|
||||
foreach (var owner in owners)
|
||||
{
|
||||
if (DoesOwnerMatch(owner, document))
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Expects birthdate in form YYYY-MM-DD and taxid in form ###-##-####
|
||||
// Expects dob in form MM/DD/YYYY and ssn in form #### (last 4)
|
||||
// Tries to match this owner and this document.
|
||||
public bool DoesOwnerMatch(CoreMemberOwner owner, OnlineIdentityFormData document)
|
||||
{
|
||||
if (string.IsNullOrEmpty(owner.BirthDate) || owner.TaxId == null || owner.TaxId.Length != 11)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (owner.TaxId.Substring(7) != document.SocialSecurityNumber)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string[] formats = { "MM/dd/yyyy", "yyyy-MM-dd" };
|
||||
var dobEntered = DateTime.ParseExact(document.DateOfBirth, formats, new CultureInfo("en-US"), DateTimeStyles.None);
|
||||
var dobDesired = DateTime.ParseExact(owner.BirthDate, formats, new CultureInfo("en-US"), DateTimeStyles.None);
|
||||
return dobEntered == dobDesired;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user