aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'PollutometerWebApi')
-rw-r--r--PollutometerWebApi/EmailSender.cs39
-rw-r--r--PollutometerWebApi/Models/Aqi.cs28
2 files changed, 47 insertions, 20 deletions
diff --git a/PollutometerWebApi/EmailSender.cs b/PollutometerWebApi/EmailSender.cs
index f62a9ca..6cc60fc 100644
--- a/PollutometerWebApi/EmailSender.cs
+++ b/PollutometerWebApi/EmailSender.cs
@@ -8,26 +8,27 @@ namespace PollutometerWebApi
{
public static void SendEmail(Aqi aqi)
{
- MailMessage mail = new MailMessage("***REMOVED***", "alek2026@edu.easj.dk");
- SmtpClient client = new SmtpClient()
- {
- Host = "mail.cock.li",
- Port = 587,
- EnableSsl = true,
- Timeout = 100,
- DeliveryMethod = SmtpDeliveryMethod.Network,
- UseDefaultCredentials = false,
- Credentials = new System.Net.NetworkCredential("***REMOVED***", "***REMOVED***")
- };
- mail.Subject = $"Pollutometer warning - {DateTime.Now}";
- mail.IsBodyHtml = true;
- mail.Body = "<h3>WARNING!</h3>\n" +
- "\n" +
- "<img src=\"https://i.imgflip.com/20b4q2.jpg\"/>\n" +
- "\n" +
+ MailMessage mail = new MailMessage("***REMOVED***", "alek2026@edu.easj.dk");
+ SmtpClient client = new SmtpClient()
+ {
+ Host = "mail.cock.li",
+ Port = 587,
+ EnableSsl = true,
+ Timeout = 100,
+ DeliveryMethod = SmtpDeliveryMethod.Network,
+ UseDefaultCredentials = false,
+ Credentials = new System.Net.NetworkCredential("***REMOVED***", "***REMOVED***")
+ };
+ mail.Subject = $"Pollutometer warning - {DateTime.Now}";
+ mail.IsBodyHtml = true;
+ mail.Body = "<h3>WARNING!</h3>\n" +
+ "\n" +
+ "<img src=\"https://i.imgflip.com/20b4q2.jpg\"/>\n" +
+ "\n" +
$"<p>The warning was triggered by {aqi.GasName}.</p>\n" +
- $"<p>Air quality index: {aqi.Value}</p>";
- client.Send(mail);
+ $"<p>Air quality index: {aqi.Value}</p>" +
+ $"<p>The AQI level is {aqi.Level}!";
+ client.Send(mail);
}
}
} \ No newline at end of file
diff --git a/PollutometerWebApi/Models/Aqi.cs b/PollutometerWebApi/Models/Aqi.cs
index 490df85..b13ddb0 100644
--- a/PollutometerWebApi/Models/Aqi.cs
+++ b/PollutometerWebApi/Models/Aqi.cs
@@ -2,7 +2,33 @@
{
public class Aqi
{
+ double _value;
+
public string GasName { get; set; }
- public double Value { get; set; }
+ public double Value
+ {
+ get
+ {
+ return _value;
+ }
+ set
+ {
+ _value = value;
+
+ if (_value >= 0 && _value <= 50)
+ Level = "Good";
+ else if (_value >= 51 && _value <= 100)
+ Level = "Moderate";
+ else if (_value >= 101 && _value <= 150)
+ Level = "Unhealthy for Sensitive Groups";
+ else if (_value >= 151 && _value <= 200)
+ Level = "Unhealthy";
+ else if (_value >= 201 && _value <= 300)
+ Level = "Very Unhealthy";
+ else if (_value >= 301 && _value <= 500)
+ Level = "Hazardous";
+ }
+ }
+ public string Level { get; set; }
}
}