Title Insurance Calculations/Underwriter
Posted: Fri Jul 24, 2015 12:33 pm
Hi, I have a request from the business to run a process that will inspect the Title Insurance Calculations entries for a particular order, and wherever the Underwriter is missing or the Underwriter.Code is not "U" (including being null), set the Underwriter accordingly. I've included some code snippets illustrating the process (edited to remove irrelevant bits). Here's the main process:
Here's OrderContactHelper.GetByType, which does what you probably suspect:
When I run this code, a couple of different errors are generated, depending on the order that I use. A couple examples of return messages/stack traces/etc. below. I'll reference these by order number, which is mostly irrelevant to the problem, but included just in case you have questions about a specific error.
Order 140-140200231
Exception Message: The specified value violates the SoftPro.ClientModel.Validations.AllowedValuesAttribute constraint.
Stack Trace:
Order 140-140203850
Exception Message: Cannot access member.
Stack Trace:
I'm assuming I'm making a mistake somewhere in the code that's responsible for setting the values. Any help or guidance on this? Thanks.
Code: Select all
dynamic title = order["Title"];
dynamic calcs = title.TitleInsuranceCalculations;
var underwriterContact = OrderContactHelper.GetByType(order, "U").FirstOrDefault(); // details in snippet below
foreach (var calc in calcs)
{
dynamic underwriter = calc.Underwriter;
if (underwriter == null)
{
dynamic newUnderwriter = (dynamic)order.CreateNew("Underwriter");
newUnderwriter.LookupCode = "FA"; // NOTE: not sure this needs to be here; was using another Underwriter instance as a guide
calc.Underwriter = newUnderwriter;
}
else if (underwriter.Code == null && underwriter.Code != "U")
{
if (underwriterContact != null)
{
underwriter.Contact = underwriterContact;
}
}
}
Code: Select all
public static IEnumerable<IOrderItem> GetByType(IOrder order, string contactType)
{
var returnList = new List<IOrderItem>();
dynamic contacts = (dynamic) order["Contacts"];
if (contacts != null)
{
foreach (var contact in contacts)
{
if (((string)contact.Code).Equals(contactType))
{
returnList.Add(contact);
}
}
}
return returnList;
}
Order 140-140200231
Exception Message: The specified value violates the SoftPro.ClientModel.Validations.AllowedValuesAttribute constraint.
Stack Trace:
Code: Select all
at SoftPro.EntityModel.ValidationConstraintInstance.Check(Object value)
at SoftPro.EntityModel.Field`1.OnValueChanging(T oldValue, T newValue)
at SoftPro.EntityModel.Field`1.set_Value(T value)
at TitleInsuranceCalculation.set_Underwriter(Underwriter )
at CallSite.Target(Closure , CallSite , Object , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Title.ClientIntegration.Application.APIServices.UnderwriterSetHandler.Execute(IOrderQuery query, IOrder order) in C:\Development\SVN\DHISource\DHI\trunk\WebApps\SoftPro.Administration\Title.ClientIntegration.Application\APIServices\UnderwriterSetHandler.cs:line 32
at Title.ClientIntegration.Application.APIServices.APIRequestProcessor.ExecuteQueryBatch(IOrderOperationBatch operationBatch, IOrder order) in C:\Development\SVN\DHISource\DHI\trunk\WebApps\SoftPro.Administration\Title.ClientIntegration.Application\APIServices\APIRequestProcessor.cs:line 153
at Title.ClientIntegration.Application.APIServices.APIRequestProcessor.ExecuteQueryBatch(IOrderOperationBatch batch, IOrderStore orderStore) in C:\Development\SVN\DHISource\DHI\trunk\WebApps\SoftPro.Administration\Title.ClientIntegration.Application\APIServices\APIRequestProcessor.cs:line 99
Exception Message: Cannot access member.
Stack Trace:
Code: Select all
at SoftPro.EntityModel.Field`1.set_Value(T value)
at TitleInsuranceCalculation.set_Underwriter(Underwriter )
at CallSite.Target(Closure , CallSite , Object , Object )
at Title.ClientIntegration.Application.APIServices.UnderwriterSetHandler.Execute(IOrderQuery query, IOrder order) in C:\Development\SVN\DHISource\DHI\trunk\WebApps\SoftPro.Administration\Title.ClientIntegration.Application\APIServices\UnderwriterSetHandler.cs:line 32
at Title.ClientIntegration.Application.APIServices.APIRequestProcessor.ExecuteQueryBatch(IOrderOperationBatch operationBatch, IOrder order) in C:\Development\SVN\DHISource\DHI\trunk\WebApps\SoftPro.Administration\Title.ClientIntegration.Application\APIServices\APIRequestProcessor.cs:line 153
at Title.ClientIntegration.Application.APIServices.APIRequestProcessor.ExecuteQueryBatch(IOrderOperationBatch batch, IOrderStore orderStore) in C:\Development\SVN\DHISource\DHI\trunk\WebApps\SoftPro.Administration\Title.ClientIntegration.Application\APIServices\APIRequestProcessor.cs:line 99