aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2017-12-04 10:14:32 +0100
committermarcinzelent <zelent.marcin@gmail.com>2017-12-04 10:14:32 +0100
commita3ad4472de9096ec0a12d15097048578b3514d4b (patch)
tree6779f35ddd2672a2b82e7817b15d29a3903e5801 /PollutometerWebApi/Controllers/ReadingsController.cs
parent644d63b7073f59290029bf084fb57db5a501309d (diff)
Improved calculating of AQI and sending e-mail.
Diffstat (limited to 'PollutometerWebApi/Controllers/ReadingsController.cs')
-rw-r--r--PollutometerWebApi/Controllers/ReadingsController.cs7
1 files changed, 4 insertions, 3 deletions
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();