public void Process(PhoneNumberAddedToDataCollector @event) { var unknownReports = this.unknownReports.GetByPhoneNumber(@event.PhoneNumber); var dataCollector = dataCollectors.GetById(@event.DataCollectorId); foreach (var item in unknownReports) { var repo = caseReportingAggregateRootRepository.Get(item.Id); repo.Report( @event.DataCollectorId, item.HealthRiskId, item.Origin, item.NumberOfMalesUnder5, item.NumberOfMalesAged5AndOlder, item.NumberOfFemalesUnder5, item.NumberOfFemalesAged5AndOlder, dataCollector.Location.Longitude, dataCollector.Location.Latitude, item.Timestamp, item.Message ); repo.ReportFromUnknownDataCollectorIdentiefied(@event.DataCollectorId); } var invalidAndUnknownReports = this.invalidAndUnknownReports.GetByPhoneNumber(@event.PhoneNumber); foreach (var item in invalidAndUnknownReports) { var repo = caseReportingAggregateRootRepository.Get(item.Id); repo.ReportInvalidReport( @event.DataCollectorId, item.PhoneNumber, item.Message, dataCollector.Location.Longitude, dataCollector.Location.Latitude, item.ParsingErrorMessage, item.Timestamp ); repo.ReportFromUnknownDataCollectorIdentiefied(@event.DataCollectorId); } }
public void Process(PhoneNumberAddedToDataCollector @event) { var dataCollector = _dataCollectors.GetById(@event.DataCollectorId); // Todo Get the correct welcome message based on the dataCollector.PreferredLanguage var welcomeMessage = "Welcome!"; var smsGenerator = _greetingHistories.GetByPhoneNumber(@event.PhoneNumber); if (smsGenerator != null) { return;// TODO: Something should be thrown } var smsGeneratorAggregateRootRepository = _messageGeneratorsAggregateRootRepository.Get(@event.DataCollectorId); smsGeneratorAggregateRootRepository.GenerateMessage(new GenerateMessage { Id = @event.DataCollectorId, Message = welcomeMessage, PhoneNumber = @event.PhoneNumber }); }
public bool DataCollectorIsRegistered(DataCollectorId id) => _dataCollectors.GetById(id) != null;