Example #1
0
            public async Task <Unit> Handle(Command command, CancellationToken cancellationToken)
            {
                var weatherUpdateEvent = command.WeatherUpdateEvent;

                var weatherForcastForZip = await weatherForecastService.GetForecastForZip(weatherUpdateEvent.ZipCode);

                var recommendations = weatherForcastForZip.WeatherData.Select(d => recommendationFactory.Create(d)).ToList();

                var outreachRecommendation = new OutreachRecommendation(weatherForcastForZip.ZipCode,
                                                                        weatherForcastForZip.CityName,
                                                                        recommendations);

                await outreachRecommendationRepository.Update(outreachRecommendation);

                return(Unit.Value);
            }
Example #2
0
        public async Task Update(OutreachRecommendation outreachRecommendation)
        {
            try
            {
                var options = new FindOneAndReplaceOptions <OutreachRecommendation>()
                {
                    IsUpsert = true
                };

                var zipFilter = Builders <OutreachRecommendation> .Filter.Eq(r => r.ZipCode, outreachRecommendation.ZipCode);

                await recommendationsCollection.FindOneAndReplaceAsync(zipFilter, outreachRecommendation, options);
            }
            catch (MongoWriteException mongoWriteException)
            {
                // TODO
            }
        }
Example #3
0
        private OutreachRecommendationsBuilder()
        {
            var start = DateTime.UtcNow;
            var end   = start.AddHours(3);

            // TODO - Use actual random values
            outreachRecommendation = new OutreachRecommendation(
                "54022",
                "River Falls",
                new List <RecommendationValue>
            {
                new RecommendationValue(
                    start,
                    end,
                    OutreachType.Email,
                    WeatherDataBuilder.Randomized().Build())
            }
                );
        }