private static RelationshipSearch SetParent_ReturnLookingForParent(PersonWithMetadata person, bool hasThisParent, bool?hasValidThisParent, bool isFemale, bool setFathersNin, int age) { if (!hasThisParent) { return(null); } if (hasValidThisParent.HasValue && hasValidThisParent.Value) { return(new RelationshipSearch { IsFemale = person.IsFemale, AgeQuant = GetAgeQuant(person.GetAge()), NinRef = person.Person.NIN, IsLookingForFemale = isFemale, IsLookingForAgeQuant = GetAgeQuant(age) }); } else { if (setFathersNin) { person.Person.FathersNIN = NinModel.GetBirthdayAndNin(age, isFemale, false, person.Randy).Item2; } else { person.Person.MothersNIN = NinModel.GetBirthdayAndNin(age, isFemale, false, person.Randy).Item2; } } return(null); }
private Tuple <DateTime, string> GetNonTakenBirthdayAndNin(PersonWithMetadata person, bool isFemale, bool hasDnummer) { int howManyTries = 0; while (true) { if (howManyTries++ > 100) { throw new ArgumentException($"Klarer ikke å lage nin for alder {person.Age}"); } var bdayAndNin = NinModel.GetBirthdayAndNin(person.Age, isFemale, hasDnummer, person.Randy); if (_idControl.TakenContains(bdayAndNin.Item2)) { continue; } var successfulAdd = _idControl.TakenAdd(bdayAndNin.Item2); if (!successfulAdd) { continue; } return(bdayAndNin); } }
private void RegisterSpouseSearch(PersonWithMetadata person, bool hasSpouse, Randomizer randy) { if (!hasSpouse) { return; } person.Married = true; var spouseSameSex = randy.Hit(_pSpouseSameSex_GivenHasValidSpouse(person)); var spouseAgeDifferential = Try(_getSpouseAgeDifferential, person); var spouseAge = person.GetAge() + spouseAgeDifferential; var spouseExists = randy.Hit(_pSpouseExists_GivenHasSpouse(person)); if (!spouseExists) { var spouseIsFemale = (person.IsFemale && spouseSameSex) || (!person.IsFemale && !spouseSameSex); person.Person.SpouseNIN = NinModel.GetBirthdayAndNin(spouseAge, spouseIsFemale, false, person.Randy).Item2; return; } var spouseDuplex = randy.Hit(_pSpouseDuplex_GivenHasValidSpouse(person)); var spouseSearch = new RelationshipSearch() { NinRef = person.Person.NIN, IsFemale = person.IsFemale, AgeQuant = GetAgeQuant(person.GetAge()), IsLookingForFemale = (person.IsFemale && spouseSameSex) || (!person.IsFemale && !spouseSameSex), IsLookingForAgeQuant = GetAgeQuant(spouseAge) }; AddSearchToDic(spouseSearch.KeyMe(), spouseSearch, spouseDuplex ? SpouseSearchDuplex : SpouseSearchNonDuplex); }