Exemplo n.º 1
0
        private void GenerateReportRegisteredEvents(
            CaseReportData caseReportData,
            AgeGroup group,
            Sex sex,
            int count,
            int healthRiskNumber)
        {
            for (int i = 0; i < count; i++)
            {
                var reportRegistered = new ReportRegistered(
                    Guid.NewGuid(),
                    caseReportData.CaseReportId,
                    (int)group,
                    (int)sex,
                    caseReportData.Latitude,
                    caseReportData.Longitude,
                    caseReportData.Timestamp,
                    caseReportData.DataCollectorId,
                    caseReportData.HealthRiskId,
                    healthRiskNumber,
                    caseReportData.PhoneNumber);

                Apply(reportRegistered);
            }
        }
Exemplo n.º 2
0
        public void ProcessReport(CaseReportData caseReportData)
        {
            if (_isProcessed)
            {
                return;
            }

            int healthRiskNumber = this.GetHealthRiskNumber(caseReportData.Message);

            GenerateReportRegisteredEvents(caseReportData, AgeGroup.AgeUnder5, Sex.Male, caseReportData.NumberOfMalesUnder5, healthRiskNumber);
            GenerateReportRegisteredEvents(caseReportData, AgeGroup.Age5AndOver, Sex.Male, caseReportData.NumberOfMalesAged5AndOlder, healthRiskNumber);
            GenerateReportRegisteredEvents(caseReportData, AgeGroup.AgeUnder5, Sex.Female, caseReportData.NumberOfFemalesUnder5, healthRiskNumber);
            GenerateReportRegisteredEvents(caseReportData, AgeGroup.Age5AndOver, Sex.Female, caseReportData.NumberOfFemalesAged5AndOlder, healthRiskNumber);
        }
Exemplo n.º 3
0
        public void Handle(ForcePublishNewCaseReport cmd)
        {
            var aggrRoot = _aggregateRootRepoForCaseReport.Get(cmd.CaseReportId);
            var data     = new CaseReportData
            {
                CaseReportId                 = cmd.CaseReportId,
                DataCollectorId              = cmd.DataCollectorId,
                HealthRiskId                 = cmd.HealthRiskId,
                Latitude                     = cmd.Latitude,
                Longitude                    = cmd.Longitude,
                Timestamp                    = cmd.Timestamp,
                NumberOfMalesUnder5          = cmd.NumberOfMalesUnder5,
                NumberOfMalesAged5AndOlder   = cmd.NumberOfMalesAged5AndOlder,
                NumberOfFemalesUnder5        = cmd.NumberOfFemalesUnder5,
                NumberOfFemalesAged5AndOlder = cmd.NumberOfFemalesAged5AndOlder,
                Message     = cmd.Message,
                PhoneNumber = cmd.Origin
            };

            aggrRoot.ProcessReport(data);
        }