/// <summary> /// Add a random <see cref="IPerson"/> to the Children collection. /// </summary> /// <param name="myChildDob"> /// This will be adusted up by when the Birth Date would occur during the pregnancy /// of a sibling unless it is the exact same date (twins). /// </param> protected internal void AddNewChildToList(DateTime myChildDob) { if (MyGender == Gender.Male) return; var dt = DateTime.Now; DateTime dtOut; if (IsTwin(myChildDob, out dtOut) && DateTime.Compare(dtOut, DateTime.MinValue) != 0) { myChildDob = dtOut; } else { //need to move Dob based on timing of siblings and biology of mother while (!IsValidDobOfChild(myChildDob)) { myChildDob = myChildDob.AddDays(PREG_DAYS + MS_DAYS); } } var myChildeAge = CalcAge(myChildDob, dt); var myChildGender = Etx.CoinToss ? Gender.Female : Gender.Male; var isChildAdult = myChildeAge >= GetMyHomeStatesAgeOfMajority(); //look for spouse at and around Dob var spouseAtChildDob = GetSpouseAt(myChildDob) ?? GetSpouseAt(myChildDob.AddDays(-1*(PREG_DAYS + MS_DAYS))) ?? GetSpouseAt(myChildDob.AddDays(PREG_DAYS + MS_DAYS)); var childLastName = string.IsNullOrWhiteSpace(spouseAtChildDob?.Est?.LastName) || spouseAtChildDob.Est?.MyGender == Gender.Female ? LastName : spouseAtChildDob.Est?.LastName; var nAmerChild = new NorthAmerican(myChildDob, myChildGender, this, spouseAtChildDob?.Est) { LastName = childLastName }; //child has ref to father, father needs ref to child var nAmerFather = spouseAtChildDob?.Est as NorthAmerican; if (nAmerFather != null && nAmerFather.MyGender == Gender.Male && nAmerFather.Children.All(x => !nAmerChild.Equals(x.Est))) { nAmerFather._children.Add(new Child(nAmerChild)); } //resolve spouse, no grand-children if (isChildAdult) { nAmerChild.ResolveSpouse(NAmerUtil.GetMaritialStatus(myChildDob, myChildGender)); nAmerChild.AlignCohabitantsHomeDataAt(DateTime.Now, nAmerChild.GetAddressAt(null)); } _children.Add(new Child(nAmerChild)); }
/// <summary> /// Sets <see cref="thisPerson"/> home-related data to the same values of <see cref="livesWithThisOne"/> /// </summary> /// <param name="thisPerson"></param> /// <param name="livesWithThisOne"></param> public static void SetNAmerCohabitants(NorthAmerican thisPerson, NorthAmerican livesWithThisOne) { if (thisPerson == null || livesWithThisOne == null) return; var addrMatchTo = livesWithThisOne.GetAddressAt(null); if (addrMatchTo == null) return; thisPerson.UpsertAddress(addrMatchTo); thisPerson._phoneNumbers.Clear(); if (livesWithThisOne._phoneNumbers.Any(p => p.Item1 == KindsOfLabels.Home)) { thisPerson._phoneNumbers.Add(livesWithThisOne._phoneNumbers.First(p => p.Item1 == KindsOfLabels.Home)); } if (thisPerson.GetAgeAt(null) >= 12 && !String.IsNullOrWhiteSpace(addrMatchTo.HomeCityArea?.GetPostalCodePrefix())) thisPerson._phoneNumbers.Add(new Tuple<KindsOfLabels, NorthAmericanPhone>(KindsOfLabels.Mobile, Phone.American(addrMatchTo.HomeCityArea.GetPostalCodePrefix()))); }