43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using System.Xml.Linq;
|
|
using System.Xml.XPath;
|
|
using CRIF.ACTion.Common;
|
|
using CRIF.ACTion.Common.Parsers;
|
|
using Landmark.OLA.Models.Individuals;
|
|
|
|
namespace CRIF.ACTion.Loan.Individuals
|
|
{
|
|
public class AddIndividualResponseParser: IResponseParser<Individual>
|
|
{
|
|
public Individual Parse(XElement xElement)
|
|
{
|
|
CheckErrors(xElement);
|
|
|
|
return ParseIndividual(xElement);
|
|
}
|
|
|
|
private static void CheckErrors(XElement xElement)
|
|
{
|
|
var error = xElement.XPathSelectElement("/actionAPI/addIndividual/errors/error",
|
|
CrifNamespaces.GetNamespaceManager(xElement));
|
|
|
|
if (error != null)
|
|
{
|
|
throw new Exception(error.Value);
|
|
}
|
|
}
|
|
|
|
public static Individual ParseIndividual(XElement xElement)
|
|
{
|
|
var individual = xElement.XPathSelectElement("/actionAPI/addIndividual/msg:appImportResponse/msg:applications/app:application/app:parties/common:individual",
|
|
CrifNamespaces.GetNamespaceManager(xElement));
|
|
|
|
var parsedIndividual = new Individual
|
|
{
|
|
FirstName = individual.Attribute(CrifNamespaces.Common + "firstName").Value
|
|
};
|
|
|
|
return parsedIndividual;
|
|
}
|
|
}
|
|
}
|