aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'PollutometerWebApi/Controllers')
-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();