예제 #1
0
        private void ComputePersonsPerRoomByZone(Date now)
        {
            var recordsByZone = new Dictionary <int, int>();

            foreach (var dwelling in Repository.GetRepository(Dwellings))
            {
                var zone = dwelling.Zone;
                recordsByZone.TryGetValue(zone, out int previousCount);
                recordsByZone[zone] = previousCount + 1;
                _personsPerRoomByZone.TryGetValue(zone, out var value);
                _personsPerRoomByZone[zone] = value + _currencyManager.ConvertToYear(dwelling.Value, now).Amount;
            }
            var temp = _personsPerRoomByZone.ToArray();

            foreach (var totals in temp)
            {
                var zone  = totals.Key;
                var value = totals.Value;
                _personsPerRoomByZone[zone] = _personsPerRoomByZone[zone] / recordsByZone[zone];
            }
        }