Files
2026-03-11 11:18:25 -05:00

69 lines
2.9 KiB
C#

using System.Xml.Linq;
using CRIF.ACTion.Common;
using CRIF.ACTion.Common.Builders;
using CRIF.ACTion.Configuration;
using Landmark.OLA.Models;
using Landmark.OLA.Models.Addresses;
using Landmark.OLA.Models.Residences;
using static CRIF.ACTion.Common.ContactMechanisms;
namespace CRIF.ACTion.Loan.Individuals
{
public class AddressesSection : CrifRequestSection
{
public AddressesSection(XNamespace sectionNamespace, CrifSettings settings)
: base(sectionNamespace, "addresses", settings)
{
}
public void AddAddress(IAddress address, CrifContactMechanism contactMechanismType)
{
ModelValidator.Validate(address);
var isCurrentAddress = contactMechanismType == CrifContactMechanism.CurrentAddress
? true : false;
var addressElement = new XElement(CrifNamespaces.Common + "address",
new XAttribute(CrifNamespaces.Common + "id", address.Id),
new XAttribute(CrifNamespaces.Common + "street1", BuilderUtils.FormatCrifData(address.Address1)),
new XAttribute(CrifNamespaces.Common + "cityName", BuilderUtils.FormatCrifData(address.City)),
new XAttribute(CrifNamespaces.Common + "state", address.State),
new XAttribute(CrifNamespaces.Common + "postalCode", address.PostalCode),
new XAttribute(CrifNamespaces.Common + "country", address.Country));
var addressType = address.GetType();
if (addressType.Equals(typeof(ResidenceAddress)) || addressType.IsSubclassOf(typeof(ResidenceAddress)))
{
var residence = (ResidenceAddress)address;
addressElement.Add(
new XAttribute(CrifNamespaces.Common + "isCurrentResFL", isCurrentAddress),
new XAttribute(CrifNamespaces.Common + "monthsResided", residence.MonthsResided));
var typeCode = CrifResidenceType.GetCrifResidenceTypeCode(residence.ResidenceType.Value);
if (typeCode != null)
{
var residenceTypeElement = new XElement(CrifNamespaces.Common + "residenceType",
new XAttribute(CrifNamespaces.Common + "CD", typeCode));
addressElement.Add(residenceTypeElement);
}
}
if (!string.IsNullOrWhiteSpace(address.Address2))
{
addressElement.Add(new XAttribute(CrifNamespaces.Common + "street2", BuilderUtils.FormatCrifData(address.Address2)));
}
if (!string.IsNullOrWhiteSpace(address.PostalCodeExt))
{
addressElement.Add(new XAttribute(CrifNamespaces.Common + "zipExt", address.PostalCodeExt));
}
AddContent(addressElement);
}
}
}