aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2017-12-04 13:01:04 +0100
committermarcinzelent <zelent.marcin@gmail.com>2017-12-04 13:01:04 +0100
commit54d1019413958e0ba24b85007c1f5f97ca19a0b3 (patch)
tree9763cbc654c7db9885633654fe405045e692d49d
parente41a7bee10dbb968913429c5d0e4a1fcbbb5b5e3 (diff)
Added levels of AQI.
-rw-r--r--PollutometerWebApi.Tests/Test.cs1
-rw-r--r--PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.dllbin4096 -> 4096 bytes
-rw-r--r--PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdbbin532 -> 536 bytes
-rw-r--r--PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dllbin16384 -> 16896 bytes
-rw-r--r--PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdbbin3984 -> 4216 bytes
-rw-r--r--PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cachebin109342 -> 109342 bytes
-rw-r--r--PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dllbin4096 -> 4096 bytes
-rw-r--r--PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdbbin532 -> 536 bytes
-rw-r--r--PollutometerWebApi.userprefs13
-rw-r--r--PollutometerWebApi/EmailSender.cs39
-rw-r--r--PollutometerWebApi/Models/Aqi.cs28
11 files changed, 56 insertions, 25 deletions
diff --git a/PollutometerWebApi.Tests/Test.cs b/PollutometerWebApi.Tests/Test.cs
index cc17234..abec015 100644
--- a/PollutometerWebApi.Tests/Test.cs
+++ b/PollutometerWebApi.Tests/Test.cs
@@ -9,6 +9,7 @@ namespace PollutometerWebApi.Tests
public void TestCase()
{
var result = AqiCalculator.CalculateAqi(new Models.Reading() {Co = 30.4, No = 1.0, So = 0.4});
+ EmailSender.SendEmail(result);
}
}
}
diff --git a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.dll b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.dll
index 4fec8a3..29a96a6 100644
--- a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.dll
+++ b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.dll
Binary files differ
diff --git a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb
index 4b521ed..d4059a7 100644
--- a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb
+++ b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb
Binary files differ
diff --git a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll
index 205cb6b..ebf4ce3 100644
--- a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll
+++ b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll
Binary files differ
diff --git a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb
index 176b41e..ca309d7 100644
--- a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb
+++ b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb
Binary files differ
diff --git a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache
index e810d97..2906fc7 100644
--- a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache
+++ b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache
Binary files differ
diff --git a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll
index 4fec8a3..29a96a6 100644
--- a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll
+++ b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll
Binary files differ
diff --git a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb
index 4b521ed..d4059a7 100644
--- a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb
+++ b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb
Binary files differ
diff --git a/PollutometerWebApi.userprefs b/PollutometerWebApi.userprefs
index 36d72e1..822fb73 100644
--- a/PollutometerWebApi.userprefs
+++ b/PollutometerWebApi.userprefs
@@ -1,16 +1,19 @@
-<Properties StartupConfiguration="{22C32F4C-0DEB-40EA-9D56-48942CBB2A07}|">
- <MonoDevelop.Ide.Workbench ActiveDocument="PollutometerWebApi/EmailSender.cs">
+<Properties StartupConfiguration="{D19CA1E0-796F-480A-996D-3DFABFC6203F}|Unit Tests">
+ <MonoDevelop.Ide.Workbench ActiveDocument="PollutometerWebApi/Models/Aqi.cs">
<Files>
<File FileName="PollutometerWebApi/AqiCalculator.cs" Line="7" Column="16" />
- <File FileName="PollutometerWebApi.Tests/Test.cs" Line="15" Column="1" />
+ <File FileName="PollutometerWebApi.Tests/Test.cs" Line="16" Column="1" />
<File FileName="PollutometerWebApi/Controllers/ReadingsController.cs" Line="71" Column="48" />
- <File FileName="PollutometerWebApi/EmailSender.cs" Line="11" Column="103" />
+ <File FileName="PollutometerWebApi/EmailSender.cs" Line="25" Column="23" />
+ <File FileName="PollutometerWebApi/Models/Aqi.cs" Line="10" Column="14" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.ItemProperties.PollutometerWebApi PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
- <BreakpointStore />
+ <BreakpointStore>
+ <Breakpoint file="/home/marcin/MonoDevelop Projects/Pollutometer-WebAPI/PollutometerWebApi/EmailSender.cs" relfile="PollutometerWebApi/EmailSender.cs" line="31" column="13" />
+ </BreakpointStore>
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.ItemProperties.PollutometerWebApi.Tests PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
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; }
}
}