diff options
author | marcinzelent <zelent.marcin@gmail.com> | 2017-11-27 12:49:35 +0100 |
---|---|---|
committer | marcinzelent <zelent.marcin@gmail.com> | 2017-11-27 12:49:35 +0100 |
commit | 3c203d43f67212570318a4fea4bc68fac13c581f (patch) | |
tree | d57a9095278b160c61cc5852ec1d6c810bf83bcb | |
parent | 10bc4d0f275f5183da672ece1d7dfa5da8375b3f (diff) |
Fixed getting latest reading.
-rw-r--r-- | AirPollutionWebApi/Controllers/ReadingsController.cs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/AirPollutionWebApi/Controllers/ReadingsController.cs b/AirPollutionWebApi/Controllers/ReadingsController.cs index 480d8c0..99965e6 100644 --- a/AirPollutionWebApi/Controllers/ReadingsController.cs +++ b/AirPollutionWebApi/Controllers/ReadingsController.cs @@ -30,7 +30,8 @@ namespace AirPollutionWebApi.Controllers [Route("api/Readings/latest")]
public IHttpActionResult GetLatestReading()
{ - var command = "SELECT MAX(TimeStamp) FROM Readings"; + var command = "SELECT * FROM Readings " +
+ "WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)"; var reading = SqlOperator.GetReadings(command)[0]; if (reading != null) return Ok(reading); |