diff options
-rw-r--r-- | PollutometerWebApi.Tests/Test.cs | 1 | ||||
-rw-r--r-- | PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.dll | bin | 4096 -> 4096 bytes | |||
-rw-r--r-- | PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb | bin | 532 -> 536 bytes | |||
-rw-r--r-- | PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll | bin | 16384 -> 16896 bytes | |||
-rw-r--r-- | PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb | bin | 3984 -> 4216 bytes | |||
-rw-r--r-- | PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache | bin | 109342 -> 109342 bytes | |||
-rw-r--r-- | PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll | bin | 4096 -> 4096 bytes | |||
-rw-r--r-- | PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb | bin | 532 -> 536 bytes | |||
-rw-r--r-- | PollutometerWebApi.userprefs | 13 | ||||
-rw-r--r-- | PollutometerWebApi/EmailSender.cs | 39 | ||||
-rw-r--r-- | PollutometerWebApi/Models/Aqi.cs | 28 |
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 Binary files differindex 4fec8a3..29a96a6 100644 --- a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.dll +++ b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.dll diff --git a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb Binary files differindex 4b521ed..d4059a7 100644 --- a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb +++ b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.Tests.pdb diff --git a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll Binary files differindex 205cb6b..ebf4ce3 100644 --- a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll +++ b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.dll diff --git a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb Binary files differindex 176b41e..ca309d7 100644 --- a/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb +++ b/PollutometerWebApi.Tests/bin/Debug/PollutometerWebApi.pdb diff --git a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache Binary files differindex e810d97..2906fc7 100644 --- a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache +++ b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.csprojResolveAssemblyReference.cache diff --git a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll Binary files differindex 4fec8a3..29a96a6 100644 --- a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll +++ b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.dll diff --git a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb Binary files differindex 4b521ed..d4059a7 100644 --- a/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb +++ b/PollutometerWebApi.Tests/obj/Debug/PollutometerWebApi.Tests.pdb 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; } } } |