Пример #1
0
 public WeatherSummaryViewModel UpdateWeather(WeatherSummary weatherSummary)
 {
     OpenWeatherIcon = OpenWeatherConfiguration.GetIconURL(weatherSummary.OpenWeatherIcon);
     Temperature     = GetShortTemperature(weatherSummary.Temperature);
     Time            = ToTimeAtLocation(weatherSummary);
     return(this);
 }
Пример #2
0
 public WeatherSummaryViewModel(WeatherSummary weatherSummary, int ordering)
 {
     Name            = weatherSummary.Location;
     Temperature     = GetShortTemperature(weatherSummary.Temperature);
     OpenWeatherIcon = OpenWeatherConfiguration.GetIconURL(weatherSummary.OpenWeatherIcon);
     Id       = weatherSummary.Id;
     Ordering = ordering;
     Time     = ToTimeAtLocation(weatherSummary);
 }
Пример #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            OpenWeatherConfiguration openWeatherConfig = Configuration.GetSection("OpenWeatherConfiguration").Get <OpenWeatherConfiguration>();

            services.AddSingleton(openWeatherConfig);

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddHttpContextAccessor();
        }
Пример #4
0
        static void Main(string[] args)
        {
            WeatherProvidersCollection providers = new WeatherProvidersCollection();
            var configuration = BuildConfiguration();

            var openWeatherConfiguration = new OpenWeatherConfiguration();

            configuration.GetSection("OpenWeather").Bind(openWeatherConfiguration);
            providers.Add(new OpenWeatherProvider(openWeatherConfiguration));

            var weatherBitMapConfig = new WeatherBitConfiguration();

            configuration.GetSection("WeatherBit").Bind(weatherBitMapConfig);
            providers.Add(new WeatherBitProvider(weatherBitMapConfig));

            var         cityName = args.Length > 0 ? args[0] : "Kyiv";
            WeatherData response = providers.GetCurrentWeatherData(cityName).GetAwaiter().GetResult();

            WriteToFile("weather.txt", response);
            Console.WriteLine(response);
        }
Пример #5
0
 public WeatherService(OpenWeatherConfiguration openWeather)
 {
     _openWeather = openWeather;
 }
Пример #6
0
 public WeatherController(ILogger <WeatherController> logger, OpenWeatherConfiguration openWeatherconfiguration, IHttpContextAccessor httpContextAccessor)
 {
     _openWeatherconfiguration = openWeatherconfiguration;
     _logger = logger;
     _httpContextAccessor = httpContextAccessor;
 }