public async Task <IActionResult> GetForecastAsync() { var temperatureSensor = new TemperatureSensor(_temperatureStorage); var pressureSensor = new PressureSensor(_pressureStorage); var humiditySensor = new HumiditySensor(_humidityStorage); var windDirectionSensor = new WindDirectionSensor(_windStorage); var windSpeedSensor = new WindSpeedSensor(_windStorage); var windDirectionStr = ""; var direct = windDirectionSensor.CurrentDirection(); { if (direct >= 337 || direct < 22) { windDirectionStr = "N"; } if (direct >= 22 && direct < 67) { windDirectionStr = "NE"; } if (direct >= 67 && direct < 112) { windDirectionStr = "E"; } if (direct >= 112 && direct < 157) { windDirectionStr = "SE"; } if (direct >= 157 && direct < 202) { windDirectionStr = "S"; } if (direct >= 202 && direct < 247) { windDirectionStr = "SW"; } if (direct >= 247 && direct < 292) { windDirectionStr = "W"; } if (direct >= 292 && direct < 337) { windDirectionStr = "NW"; } } var result = new PrimaryDataDTO() { Date = DateTime.UtcNow.AddDays(-7).ToShortDateString(), Time = DateTime.Now.TimeOfDay.ToString().Substring(0, 5), Humidity = (int)humiditySensor.CurrentHumidity().Value, Pressure = pressureSensor.CurrentPressure().Value, Temperature = (int)temperatureSensor.CurrentTemperature().Value, WindDirection = windDirectionSensor.CurrentDirection(), WindSpeed = windSpeedSensor.CurrentSpeed().Value, WindDirectionStr = windDirectionStr }; return(Ok(result)); }