From 3c203d43f67212570318a4fea4bc68fac13c581f Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Mon, 27 Nov 2017 12:49:35 +0100 Subject: Fixed getting latest reading. --- AirPollutionWebApi/Controllers/ReadingsController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'AirPollutionWebApi/Controllers/ReadingsController.cs') 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); -- cgit v1.2.3