Example #1
0
        public async Task <StationWeatherDTO> GetAsync([FromQuery(Name = "stationName")] string stationName)
        {
            FavoriteStation       station;
            WeatherForecastReport weatherForecast;

            if (string.IsNullOrEmpty(stationName))
            {
                station = await _stationService.GetFavoriteStation();
            }
            else
            {
                station = await _stationService.GetFavoriteStation(stationName);
            }


            if (_weatherService.FeatureEnabled)
            {
                weatherForecast = await _weatherService.GetDailyForeCastAsync(station.StationCoordinates);
            }
            else
            {
                weatherForecast = new WeatherForecastReport(new WeatherForecast[] { });
            }
            return(new StationWeatherDTO
            {
                Station = station,
                ForecastReport = weatherForecast
            });
        }
Example #2
0
        public async Task <StationWeatherDTO> GetAsync([FromQuery(Name = "stationName")] string stationName)
        {
            FavoriteStation       station;
            WeatherForecastReport weatherForecast;
            var showingClosestStationWithBikes = false;
            var originalStationName            = "";

            if (string.IsNullOrEmpty(stationName))
            {
                station = await _stationService.GetFavoriteStation();
            }
            else
            {
                station = await _stationService.GetFavoriteStation(stationName);
            }

            if (station.AvailableBikes == 0)
            {
                originalStationName            = station.Name;
                showingClosestStationWithBikes = true;
                station = await _stationService.GetClosestAvailableStation(station);
            }

            if (_weatherService.FeatureEnabled)
            {
                weatherForecast = await _weatherService.GetDailyForeCastAsync(station.StationCoordinates);
            }
            else
            {
                weatherForecast = new WeatherForecastReport(new WeatherForecast[] { });
            }
            return(new StationWeatherDTO
            {
                Station = station,
                OriginalStationName = originalStationName,
                ShowingClosestStationWithBikes = showingClosestStationWithBikes,
                ForecastReport = weatherForecast
            });
        }
Example #3
0
        public async Task <WeatherForecastReport> GetDailyForeCastAsync(StationCoordinates coordinates)
        {
            var weatherForcastReport = new WeatherForecastReport(
                new[]
                { new WeatherForecast(
                      new Precipitation(2.0, PrecipitationType.Rain),
                      new Temperature(2, 5, 2),
                      new Wind(10),
                      "Light Rain",
                      "Boring weather",
                      new DateTime(1979, 07, 28, 22, 35, 5,
                                   DateTimeKind.Utc)),

                  new WeatherForecast(
                      new Precipitation(2.0, PrecipitationType.Snow),
                      new Temperature(2, 5, 2),
                      new Wind(10),
                      "Light Snow",
                      "Snowy weather",
                      new DateTime(1979, 07, 28, 22, 40, 5,
                                   DateTimeKind.Utc)) });

            return(await Task.FromResult(weatherForcastReport));
        }