first commit
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Common.Parsers;
|
||||
using Landmark.OLA.Models.Loan;
|
||||
|
||||
namespace CRIF.ACTion.Loan
|
||||
{
|
||||
public class DealershipResponseParser : IResponseParser<DealershipAuthRequest>
|
||||
{
|
||||
public DealershipAuthRequest Parse(XElement xdoc)
|
||||
{
|
||||
try
|
||||
{
|
||||
var application = xdoc.Descendants(Common.CrifNamespaces.App + "application").GetEnumerator();
|
||||
application.MoveNext();
|
||||
|
||||
if(application.Current == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var applicationId = application.Current.Attribute(Common.CrifNamespaces.App + "applicationID")?.Value;
|
||||
|
||||
var primaryBorrower = xdoc.Descendants(Common.CrifNamespaces.App + "primaryBorrower").GetEnumerator();
|
||||
primaryBorrower.MoveNext();
|
||||
var primaryBorrowerRef = primaryBorrower.Current.Attribute(Common.CrifNamespaces.Common + "idRef").Value;
|
||||
|
||||
string applicantLastName = null;
|
||||
var individual = xdoc.Descendants(Common.CrifNamespaces.Common + "individual").GetEnumerator();
|
||||
while(individual.MoveNext())
|
||||
{
|
||||
if(individual.Current.Attribute(Common.CrifNamespaces.Common + "id").Value.Equals(primaryBorrowerRef))
|
||||
{
|
||||
applicantLastName = individual.Current.Attribute(Common.CrifNamespaces.Common + "lastName")?.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (applicantLastName == null)
|
||||
{
|
||||
// Check for Company as primary applicant
|
||||
var company = xdoc.Descendants(Common.CrifNamespaces.Common + "company").GetEnumerator();
|
||||
while (company.MoveNext())
|
||||
{
|
||||
if (company.Current.Attribute(Common.CrifNamespaces.Common + "id").Value.Equals(primaryBorrowerRef))
|
||||
{
|
||||
applicantLastName = company.Current.Attribute(Common.CrifNamespaces.Common + "tradeName").Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if (applicantLastName == null)
|
||||
{
|
||||
// Check for DBA/Trust Name as primary applicant
|
||||
var company = xdoc.Descendants(Common.CrifNamespaces.Common + "company").GetEnumerator();
|
||||
while (company.MoveNext())
|
||||
{
|
||||
if (company.Current.Attribute(Common.CrifNamespaces.Common + "id").Value.Equals(primaryBorrowerRef))
|
||||
{
|
||||
applicantLastName = company.Current.Attribute(Common.CrifNamespaces.Common + "code").Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
var channel = xdoc.Descendants(Common.CrifNamespaces.Common + "channel");
|
||||
var channelEnum = channel.GetEnumerator();
|
||||
channelEnum.MoveNext();
|
||||
var dealershipCode = channelEnum.Current.Attribute(Common.CrifNamespaces.Common + "code")?.Value;
|
||||
var dealershipName = channelEnum.Current.Attribute(Common.CrifNamespaces.Common + "dbaName")?.Value;
|
||||
var dealershipPassword = channelEnum.Current.Attribute(Common.CrifNamespaces.Common + "costCenterCode")?.Value;
|
||||
|
||||
var isActiveFlag = channelEnum.Current.Attribute(Common.CrifNamespaces.Common + "isActiveFL")?.Value;
|
||||
if(isActiveFlag == "false")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var classificationItems = channel.Descendants(Common.CrifNamespaces.Common + "channelClassificationItem").GetEnumerator();
|
||||
while (classificationItems.MoveNext())
|
||||
{
|
||||
if(string.Equals(classificationItems.Current.Attribute(Common.CrifNamespaces.Common + "name").Value, "Dealer", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return new DealershipAuthRequest(dealershipCode, dealershipName, dealershipPassword, applicantLastName, applicationId);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new FormatException("CRIF XML is in an unexpected layout.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user