public PersonStatistics GetClosestStatisticByAgeQuant(PersonWithMetadata person, Func <PersonStatistics, bool> isValidForMe = null) { var ageQ = person.AgeQuants; if (ageQ <= 0) { return(StatisticsByAgeQuants.ContainsKey(1) ? StatisticsByAgeQuants[1] : this); } do { if (StatisticsByAgeQuants.ContainsKey(ageQ) && (isValidForMe == null || isValidForMe(StatisticsByAgeQuants[ageQ]))) { return(StatisticsByAgeQuants[ageQ]); } } while (ageQ-- > 0); return(this); }
public void FromImport(Person p, int ageQuant) { _howManyTaken++; foreach (var stat in Statistics) { stat.Value.Update(p, ageQuant); } foreach (var customStat in CustomModels.Where(c => c.Value != null)) { customStat.Value.FromImport(p, ageQuant); } if (StatisticsByAgeQuants != null && StatisticsByAgeQuants.ContainsKey(ageQuant)) { StatisticsByAgeQuants[ageQuant].FromImport(p, ageQuant); } }
public void AfterImport(Dictionary <string, PregNode> applicablepersons, Dictionary <string, PregNode> allpersons) { NumberOfPersons += applicablepersons.Count; foreach (var customStat in CustomModels.Where(c => c.Value != null)) { customStat.Value.AfterImport(applicablepersons, allpersons); } if (StatisticsByAgeQuants != null) { foreach (var ageQuant in applicablepersons.Values.Where(y => y.Confirmed).GroupBy(x => x.AgeQuants)) { if (StatisticsByAgeQuants.ContainsKey(ageQuant.Key)) { StatisticsByAgeQuants[ageQuant.Key].AfterImport(ageQuant.ToDictionary(k => k.Nin, v => v), allpersons); } } } }