From a3ad4472de9096ec0a12d15097048578b3514d4b Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Mon, 4 Dec 2017 10:14:32 +0100 Subject: Improved calculating of AQI and sending e-mail. --- PollutometerWebApi/Controllers/ReadingsController.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'PollutometerWebApi/Controllers/ReadingsController.cs') diff --git a/PollutometerWebApi/Controllers/ReadingsController.cs b/PollutometerWebApi/Controllers/ReadingsController.cs index 9767645..f915e17 100644 --- a/PollutometerWebApi/Controllers/ReadingsController.cs +++ b/PollutometerWebApi/Controllers/ReadingsController.cs @@ -12,8 +12,6 @@ namespace PollutometerWebApi.Controllers public IHttpActionResult GetAllReadings() { - Task.Run(() => EmailService.Start()); - var command = "SELECT * FROM Readings"; var readings = SqlOperator.GetReadings(command); @@ -67,7 +65,10 @@ namespace PollutometerWebApi.Controllers { if (reading != null) { - SqlOperator.PostReading(reading); + SqlOperator.PostReading(reading); + var aqi = AqiCalculator.CalculateAqi(reading); + if (aqi.Value > 151) + EmailSender.SendEmail(aqi); return Ok(); } else return BadRequest(); -- cgit v1.2.3