public async Task Handle(WeedDetectedMessage message, CancellationToken cancellationToken)
        {
            Console.WriteLine($"Weed detected:{message.FieldId} {message.OrganizationId} {message.Percentage} {message.Severity}");

            var field = await _fieldService.GetAsync(message.FieldId, message.OrganizationId);

            field.Status = message.Severity == DangerLevel.Low || message.Severity == DangerLevel.High
                ? FieldStatus.NeedAttention
                : FieldStatus.Critical;
            await _fieldService.UpdateAsync(field);

            var rec = await _recommendationService.GetWeedDetectedRecommendation(message);

            var weed = await _weedService.GetAsync(message.WeedId);

            _messageService.AddWeedDetectedMessage(new WeedDetectedMessageWithRecommendation()
            {
                FieldId        = message.FieldId,
                OrganisationId = message.OrganizationId,
                Recommendation = rec,
                Severity       = message.Severity,
                WeedName       = weed.Kind
            });
        }
Beispiel #2
0
 public async Task <IActionResult> Get(Guid id)
 {
     return(Single(await _weedService.GetAsync(id)));
 }