Пример #1
0
        public void Process(CaseReportReceived @event)
        {
            var today = Day.From(@event.Timestamp);

            for (var day = today; day < today + 7; day++)
            {
                var totals = _caseReportTotalsRepository.GetById(day);
                if (totals != null)
                {
                    totals.FemalesUnder5 += @event.NumberOfFemalesUnder5;
                    totals.MalesUnder5   += @event.NumberOfMalesUnder5;
                    totals.FemalesOver5  += @event.NumberOfFemalesAged5AndOlder;
                    totals.MalesOver5    += @event.NumberOfMalesAged5AndOlder;

                    _caseReportTotalsRepository.Update(totals);
                }
                else
                {
                    totals = new CaseReportTotals()
                    {
                        Id            = day,
                        FemalesUnder5 = @event.NumberOfFemalesUnder5,
                        MalesUnder5   = @event.NumberOfMalesUnder5,
                        FemalesOver5  = @event.NumberOfFemalesAged5AndOlder,
                        MalesOver5    = @event.NumberOfMalesAged5AndOlder
                    };

                    _caseReportTotalsRepository.Insert(totals);
                }
            }
        }
Пример #2
0
        public void Process(CaseReportReceived @event)
        {
            var dataCollector = _dataCollectors.GetById(@event.DataCollectorId);

            if (dataCollector.InTraining)
            {
                return;                           // don't inlcude training data
            }
            var today = Day.From(@event.Timestamp);

            for (var day = today; day < today + 7; day++)
            {
                var totals = _caseReportTotalsRepository.GetById(day);
                if (totals != null)
                {
                    totals.FemalesUnder5 += @event.NumberOfFemalesUnder5;
                    totals.MalesUnder5   += @event.NumberOfMalesUnder5;
                    totals.FemalesOver5  += @event.NumberOfFemalesAged5AndOlder;
                    totals.MalesOver5    += @event.NumberOfMalesAged5AndOlder;

                    _caseReportTotalsRepository.Update(totals);
                }
                else
                {
                    totals = new CaseReportTotals()
                    {
                        Id            = day,
                        FemalesUnder5 = @event.NumberOfFemalesUnder5,
                        MalesUnder5   = @event.NumberOfMalesUnder5,
                        FemalesOver5  = @event.NumberOfFemalesAged5AndOlder,
                        MalesOver5    = @event.NumberOfMalesAged5AndOlder
                    };

                    _caseReportTotalsRepository.Insert(totals);
                }
            }
        }