Пример #1
0
        public async Task Consume(ConsumeContext <NewSightingReported> context)
        {
            var reportedAnalysis = _analyzerRepertoire.All()
                                   .Select(e => e.Analyze(context.Message, _sightingRepository))
                                   .ToArray();

            var sightingRecord = _protocolTranslator.TranslateToRecord <T>(context.Message, reportedAnalysis);

            _sightingRepository.Add(sightingRecord);

            var suspiciousResults = reportedAnalysis.Where(e => e.IsSuspicious).ToArray();

            if (suspiciousResults.Any())
            {
                InvestigateSighting investigateCommand = _protocolTranslator.Translate(context.Message, suspiciousResults);
                await context.Send(_routeRegistry.For <InvestigateSighting>(), investigateCommand);
            }
        }