I use VS2012, WindowsApp,c#. For my Person list, I would like to use FirstOrDefault for PrimaryPersonID and SecondaryPersonID properties.
My controls work fine in the UI, but I need logic to display properly.
If both PrimaryPersonID and SecondPersonID exists, set Primary as first.
If only a PrimaryPersonID exists and no SecondaryPersonID, Secondary can be null.
If neither exists, set null as default. So null is acceptable for both.
protected void ValidatePersonType(ValidationResults results)
{
ValidationResult vr = new ValidationResult();
if (this.CaseRecord.PrimaryPersonID != null && this.CaseRecord.SecondaryPersonID != null)
{
PrimaryPersonID = CaseRecord.GetPersonByID(PersonID.Value).FirstOrDefault();
}
else
{
if (PersonList.Count == 0)
{
PrimaryPersonID == null;
SecondaryPersonID == null;
}
}
Any help is appreciated. If using FirstOrDefault is wrong, I just need help with correct logic. Thanks.