예제 #1
0
        public void Execute()
        {
            ForegroundColor = Yellow;
            WriteLine($"\n Creating database weather forecast for {_years / 365} day(s)...\n");
            using (ILifetimeScope scope = Program.Container.BeginLifetimeScope())
            {
                IWeatherConditionsService weatherConditions = scope.Resolve <IWeatherConditionsService>();
                INoSqlProvider            provider          = scope.Resolve <INoSqlProvider>();

                WeatherForecast       forecast   = weatherConditions.GetWeatherForecast(_years);
                List <DaysSummaryDto> summaryDto = forecast.Days.Select(Mapper.Map <DaysSummaryDto>).ToList();

                provider.Add("Forecast", summaryDto);
            }

            ForegroundColor = Green;
            WriteLine("Done. ");
            ResetColor();
        }
예제 #2
0
        public void Execute()
        {
            ForegroundColor = Yellow;
            WriteLine($"\n Retrieving conditions for {_years / 365 } year(s)...\n");
            using (ILifetimeScope scope = Container.BeginLifetimeScope())
            {
                IWeatherConditionsService weatherConditions = scope.Resolve <IWeatherConditionsService>();
                WeatherForecastSummaryDto summaryDto        =
                    Map <WeatherForecastSummaryDto>(
                        weatherConditions.GetWeatherForecastSummary(_years));

                WriteLine($"\t1) Drought days: [{summaryDto.DroughtDays}]");
                WriteLine($"\t2) Rainy days: [{summaryDto.RainyDays}]");
                WriteLine($"\t\ta) Maximum day of instability: [{summaryDto.DayOfMaximumInstability}]");
                WriteLine($"\t\tb) Perimeter: [{summaryDto.Perimeter} Km]");
                WriteLine($"\t3) Periods of optimal pressure and temperature conditions: [{summaryDto.OptimalDays}]");
            }

            ResetColor();
        }