/// <summary> /// Handles details of adding <see cref="addr"/> to /// this instance's history of addresses. /// </summary> /// <param name="addr"></param> protected internal void UpsertAddress(ResidentAddress addr) { if (addr == null) return; //TODO enhance to have previous address _addresses.Clear(); _addresses.Add(addr); }
/// <summary> /// Utility method to assign the <see cref="addr"/> to this intance, /// the spouse and children who are under <see cref="UsState.AGE_OF_ADULT"/> /// given the <see cref="dt"/>. /// </summary> /// <param name="dt">Null for current time.</param> /// <param name="addr"></param> public void AlignCohabitantsHomeDataAt(DateTime? dt, ResidentAddress addr) { if (addr == null) return; UpsertAddress(addr); var ms = GetMaritalStatusAt(dt); if ((ms == MaritialStatus.Married || ms == MaritialStatus.Remarried) && GetSpouseAt(dt) != null) { NAmerUtil.SetNAmerCohabitants((NorthAmerican)GetSpouseAt(dt).Est, this); } var underAgeChildren = _children.Where( x => x.Est is NorthAmerican && !((NorthAmerican) x.Est).IsLegalAdult(dt)) .ToList(); if (underAgeChildren.Count <= 0) return; foreach (var child in underAgeChildren) NAmerUtil.SetNAmerCohabitants((NorthAmerican)child.Est, this); }