This commit is contained in:
2021-02-24 00:16:06 +00:00
parent 1f56291f9a
commit 12782bec71

View File

@@ -42,12 +42,11 @@ namespace AyaNova.Biz
//Now get the actual property name from the available fields using the lt key
string RequiredPropertyName = FF.FieldKey;
//Is it a child collection field?
//Is it an indexed collection field?
if (RequiredPropertyName.Contains("."))
{
/*
flag errors to include parent e.g in PO item validation error field name could be "Items[3].QuantityReceived" to indicate poitems collection 4th row has error in qtyreceived
flag errors to include parent e.g in PO item validation error field name could be "Items[3].QuantityReceived" to indicate poitems collection 4th row has error in qtyreceived
Note: collections are logically never more than 3 deep so for example the deepest would be workorder granchildren: e.g. Workorder.Items.Parts and most
are two deep however like Po.PoItems.field
for purposes of rule checking they would be flagged by their immediate parent "Items[3].QuantityReceived" for po or for workorder it could be
@@ -89,38 +88,32 @@ namespace AyaNova.Biz
}
}
var item = proposedObject.GetType().GetProperty(FieldKeyParts[0]).GetValue(proposedObject, null);
if (item is System.Collections.IEnumerable)
{
foreach (object o in (item as System.Collections.IEnumerable))
{
var subitem = o.GetType().GetProperty(FieldKeyParts[1]).GetValue(o, null);
}
}
else
{
// reflect over item
}
// object propertyValue = proposedObject.GetType().GetProperty(RequiredPropertyName).GetValue(proposedObject, null);
// var item = proposedObject.GetType().GetProperty(FieldKeyParts[0]).GetValue(proposedObject, null);
// if (item is System.Collections.IEnumerable)
// {
// foreach (object o in (item as System.Collections.IEnumerable))
// {
// var subitem = o.GetType().GetProperty(FieldKeyParts[1]).GetValue(o, null);
// }
// }
// else
// {
// // reflect over item
// }
// // object propertyValue = proposedObject.GetType().GetProperty(RequiredPropertyName).GetValue(proposedObject, null);
}
else
{
//It's a simple property on the main object
//use reflection to get the underlying value from the proposed object to be saved
object propertyValue = proposedObject.GetType().GetProperty(RequiredPropertyName).GetValue(proposedObject, null);
if (propertyValue == null || string.IsNullOrWhiteSpace(propertyValue.ToString()))
//biz.AddError(ApiErrorCode.VALIDATION_REQUIRED, FldLtKey);//was returning the ltkey in the error but that's not a match to the client end object so instead...
biz.AddError(ApiErrorCode.VALIDATION_REQUIRED, RequiredPropertyName);
}
}
}
}
}
internal static
}//eoc
}//ens