public async Task <WeedDetectedRecommendation> GetWeedDetectedRecommendation(WeedDetectedMessage message)
        {
            var field = await _fieldRepository.GetAsync(message.FieldId);

            if (field == null)
            {
                Console.WriteLine($"Field {message.FieldId} was not found.");
                return(null);
            }

            var pesticides = (await _pesticideRepository.BrowseAsync(x => true));

            if (pesticides == null)
            {
                Console.WriteLine($"Error while getting pesticides.");
                return(null);
            }

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

            if (weed == null)
            {
                Console.WriteLine($"Weed {message.FieldId} was not found.");
                return(null);
            }

            if (field.CurrentCrop == null)
            {
                Console.WriteLine("Field is empty. No need to recommend.");
                return(null);
            }

            var currentCulture = await _cultureRepository.GetAsync(field.CurrentCrop.CultureId);

            pesticides = pesticides.Where(x => weed.Pesticides.Any(p => p.PesticideId == x.Id) &&
                                          !x.ComponentsIds.Intersect(currentCulture.ForbiddenComponents).Any());

            var pesticidesWithDose = weed.Pesticides.Where(x => pesticides.Any(p => p.Id == x.PesticideId)).ToList();

            if (pesticidesWithDose.Count == 0)
            {
                Console.WriteLine("Unable to find recommendation");
                return(null);
            }

            return(new WeedDetectedRecommendation()
            {
                Pesticides = pesticidesWithDose
            });
        }
 public async Task <WeedDto> GetAsync(Guid id)
 {
     return(_mapper.Map <WeedDto>(await _repository.GetAsync(id)));
 }