first commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Common;
|
||||
using CRIF.ACTion.Common.Builders;
|
||||
using CRIF.ACTion.Configuration;
|
||||
using Landmark.OLA.Models.Assets;
|
||||
|
||||
namespace CRIF.ACTion.Loan.Assets
|
||||
{
|
||||
public class VehicleValuationsSection : CrifRequestSection
|
||||
{
|
||||
public VehicleValuationsSection(XNamespace sectionNamespace, CrifSettings settings)
|
||||
: base(sectionNamespace, "vehicleValuations", settings)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void AddVehicleValuation(Vehicle vehicle)
|
||||
{
|
||||
//If there's no vehicle type, it's likely a preapproval and doesn't need this element
|
||||
if (vehicle is null || vehicle.Type is null)
|
||||
return;
|
||||
|
||||
var valuationElement = new XElement(CrifNamespaces.Common + "vehicleValuation",
|
||||
new XAttribute(CrifNamespaces.Common + "id", vehicle.ValuationId),
|
||||
new XAttribute(CrifNamespaces.Common + "valuationType", "Manual"),
|
||||
new XAttribute(CrifNamespaces.Common + "make", BuilderUtils.FormatCrifData(vehicle.Make)),
|
||||
new XAttribute(CrifNamespaces.Common + "model", BuilderUtils.FormatCrifData(vehicle.Model)),
|
||||
new XAttribute(CrifNamespaces.Common + "year", vehicle.Year.Value),
|
||||
new XAttribute(CrifNamespaces.Common + "newUsed", vehicle.Condition.Value.ToString()),
|
||||
new XAttribute(CrifNamespaces.Common + "estimatedValue", vehicle.InitialEstimatedValue));
|
||||
|
||||
var valuationValueTypesElement = new XElement(CrifNamespaces.Common + "vehicleValuationValueTypes");
|
||||
valuationValueTypesElement.Add(new XElement(CrifNamespaces.Common + "vehicleValuationValueType",
|
||||
new XAttribute(CrifNamespaces.Common + "valueType", "Manual"),
|
||||
new XAttribute(CrifNamespaces.Common + "baseValue", vehicle.InitialEstimatedValue)
|
||||
));
|
||||
|
||||
valuationElement.Add(valuationValueTypesElement);
|
||||
|
||||
if (vehicle.Mileage.HasValue)
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "mileage", vehicle.Mileage.Value));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Color))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "color", BuilderUtils.FormatCrifData(vehicle.Color)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Body))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "body", BuilderUtils.FormatCrifData(vehicle.Body)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Series))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "series", BuilderUtils.FormatCrifData(vehicle.Series)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Style))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "style", BuilderUtils.FormatCrifData(vehicle.Style)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.Trim))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "trim", BuilderUtils.FormatCrifData(vehicle.Trim)));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.VIN))
|
||||
{
|
||||
if (vehicle.Type != Landmark.OLA.Models.Assets.Enums.VehicleType.PWC)
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "vin", BuilderUtils.FormatCrifData(vehicle.VIN)));
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(vehicle.StateTitled))
|
||||
{
|
||||
valuationElement.Add(new XAttribute(CrifNamespaces.Common + "state", BuilderUtils.FormatCrifData(vehicle.StateTitled)));
|
||||
}
|
||||
|
||||
AddContent(valuationElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user