Пример #1
0
        public async Task OnGet()
        {
            // var homePageFeatures = _configuration.GetSection("Features:HomePage");
            //if(homePageFeatures.GetValue<bool>("EnableGreeting"))
            // {
            //     Greeting = _greetingService.GetRandomGreeting();
            // }

            //ShowWeatherForecast = homePageFeatures.GetValue<bool>("EnableWeatherForecast");

            //var features = new Features();
            //_configuration.Bind("Features:HomePage", features);

            //if (features.EnableGreeting)
            //{
            //    Greeting = _greetingService.GetRandomGreeting();
            //}

            if (_homePageConfig.EnableGreeting)
            {
                Greeting = _greetingService.GetRandomGreeting();
            }

            ShowWeatherForecast = _homePageConfig.EnableWeatherForecast &&
                                  _weatherForecaster.ForecastEnabled;

            if (ShowWeatherForecast)
            {
                //var title = homePageFeatures["ForecastSectionTitle"];
                var title = _homePageConfig.ForecastSectionTitle;
                ForecastSectionTitle = string.IsNullOrEmpty(title) ? "How's the weather?" : title;

                var currentWeather = await _weatherForecaster.GetCurrentWeatherAsync();

                if (currentWeather != null)
                {
                    switch (currentWeather.Description)
                    {
                    case "Sun":
                        WeatherDescription = "It's sunny right now. A great day for tennis!";
                        break;

                    case "Cloud":
                        WeatherDescription = "It's cloudy at the moment and the outdoor courts are in use.";
                        break;

                    case "Rain":
                        WeatherDescription = "We're sorry but it's raining here. No outdoor courts in use.";
                        break;

                    case "Snow":
                        WeatherDescription = "It's snowing!! Outdoor courts will remain closed until the snow has cleared.";
                        break;
                    }
                }
            }
            var productsResult = await _productsApiClient.GetProducts();

            Products = productsResult.Products;
        }
Пример #2
0
        public async Task OnGet()
        {
            if (_homePageConfiguration.EnableGreeting)
            {
                Greeting = _greetingService.GetRandomGreeting();
            }

            ShowWeatherForecast = _homePageConfiguration.EnableWeatherForecast &&
                                  _weatherForecaster.ForecastEnabled;


            if (ShowWeatherForecast)
            {
                var title = _homePageConfiguration.ForecastSectionTitle;
                ForecastSectionTitle = string.IsNullOrEmpty(title) ? "How's the weather" : title;

                var currentWeather = await _weatherForecaster.GetCurrentWeatherAsync();

                if (currentWeather != null)
                {
                    switch (currentWeather.Description)
                    {
                    case "Sun":
                        WeatherDescription = "Sunny";
                        break;

                    case "Cloud":
                        WeatherDescription = "Cloudy";
                        break;

                    case "Rain":
                        WeatherDescription = "Rainy";
                        break;

                    case "Snow":
                        WeatherDescription = "Snowy";
                        break;
                    }
                }
            }
        }
Пример #3
0
        public async Task OnGet()
        {
            if (_homePageConfig.EnableGreeting)
            {
                Greeting = _greetingService.GetRandomGreeting();
            }

            ShowWeatherForecast = _homePageConfig.EnableWeatherForecast &&
                                  _weatherForecaster.ForecastEnabled;

            if (ShowWeatherForecast)
            {
                var title = _homePageConfig.ForecastSectionTitle;
                ForecastSectionTitle = string.IsNullOrEmpty(title) ? "How's the weather?" : title;

                var currentWeather = await _weatherForecaster.GetCurrentWeatherAsync();

                if (currentWeather != null)
                {
                    switch (currentWeather.Description)
                    {
                    case "Sun":
                        WeatherDescription = "It's sunny right now. A great day for tennis!";
                        break;

                    case "Cloud":
                        WeatherDescription = "It's cloudy at the moment and the outdoor courts are in use.";
                        break;

                    case "Rain":
                        WeatherDescription = "We're sorry but it's raining here. No outdoor courts in use.";
                        break;

                    case "Snow":
                        WeatherDescription = "It's snowing!! Outdoor courts will remain closed until the snow has cleared.";
                        break;
                    }
                }
            }
        }
        public async Task OnGet()
        {
            if (_homePageConfig.EnableGreeting)
            {
                Greeting = _greetingService.GetRandomGreeting();
            }

            ShowWeatherForecast = _homePageConfig.EnableWeatherForecast;

            if (ShowWeatherForecast)
            {
                var title = _homePageConfig.ForecastSectionTitle;

                ForecastSectionTitle = title;
                var currenWeather = await _weatherForecaster.GetCurrentWeatherAsync();

                if (currenWeather != null)
                {
                    switch (currenWeather.Description)
                    {
                    case "Sun":
                        WeatherDescription = "Piękne słońce";
                        break;

                    case "Cloud":
                        WeatherDescription = "Zachmurzenie, czapka niepotrzebna";
                        break;

                    case "Rain":
                        WeatherDescription = "Pada, pada, pada deszcze";
                        break;
                    }
                }
            }
            var productsResult = await _productsApiClient.GetProducts();

            Products = productsResult.Products;
        }