diff options
author | marcinzelent <zelent.marcin@gmail.com> | 2017-11-23 10:55:32 +0100 |
---|---|---|
committer | marcinzelent <zelent.marcin@gmail.com> | 2017-11-23 10:55:32 +0100 |
commit | efc3555b0cc3ddeb0404abcbc7030627617c9719 (patch) | |
tree | c2b5c4c8cc74b37a46215e985669a2c1e1282f91 | |
parent | d5b8f7f8762cd8270a44227f23ce6f7a88ae3eac (diff) |
Changed the way data is being get from database.
-rw-r--r-- | AirPollutionWebApi.userprefs | 4 | ||||
-rw-r--r-- | AirPollutionWebApi/Controllers/ReadingsController.cs | 3 | ||||
-rw-r--r-- | AirPollutionWebApi/Models/Reading.cs | 3 | ||||
-rw-r--r-- | AirPollutionWebApi/Singletons/Singleton.cs | 26 | ||||
-rw-r--r-- | AirPollutionWebApi/bin/AirPollutionWebApi.dll | bin | 11776 -> 11776 bytes | |||
-rw-r--r-- | AirPollutionWebApi/bin/AirPollutionWebApi.pdb | bin | 2512 -> 2568 bytes | |||
-rw-r--r-- | AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll | bin | 11776 -> 11776 bytes | |||
-rw-r--r-- | AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb | bin | 2512 -> 2568 bytes |
8 files changed, 22 insertions, 14 deletions
diff --git a/AirPollutionWebApi.userprefs b/AirPollutionWebApi.userprefs index 22153ef..6cd10e6 100644 --- a/AirPollutionWebApi.userprefs +++ b/AirPollutionWebApi.userprefs @@ -11,8 +11,8 @@ <File FileName="../RestCustomer/RestCustomer.Service/Global.asax" Line="1" Column="1" /> <File FileName="../RestCustomer/RestCustomer.Service/Global.asax.cs" Line="1" Column="1" /> <File FileName="AirPollutionWebApi/Global.asax.cs" Line="1" Column="1" /> - <File FileName="../RestCustomer/RestCustomer.Service/Web.config" Line="1" Column="1" /> - <File FileName="AirPollutionWebApi/Web.config" Line="1" Column="1" /> + <File FileName="../RestCustomer/RestCustomer.Service/Web.config" Line="25" Column="17" /> + <File FileName="AirPollutionWebApi/Web.config" Line="14" Column="42" /> </Files> </MonoDevelop.Ide.Workbench> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" /> diff --git a/AirPollutionWebApi/Controllers/ReadingsController.cs b/AirPollutionWebApi/Controllers/ReadingsController.cs index 3ffe624..c8c8087 100644 --- a/AirPollutionWebApi/Controllers/ReadingsController.cs +++ b/AirPollutionWebApi/Controllers/ReadingsController.cs @@ -14,7 +14,8 @@ namespace AirPollutionWebApi.Controllers public ReadingsController() { } public IEnumerable<Reading> GetAllReadings() - { + {
+ Singleton.Instance.GetData(); return Singleton.Instance.Readings; } diff --git a/AirPollutionWebApi/Models/Reading.cs b/AirPollutionWebApi/Models/Reading.cs index b829711..4880659 100644 --- a/AirPollutionWebApi/Models/Reading.cs +++ b/AirPollutionWebApi/Models/Reading.cs @@ -4,7 +4,8 @@ namespace AirPollutionWebApi.Models { public class Reading { - public DateTime TimeStamp { get; set; } + public int Id { get; set; } + public int TimeStamp { get; set; } public int Co { get; set; } public int No { get; set; } public int So { get; set; } diff --git a/AirPollutionWebApi/Singletons/Singleton.cs b/AirPollutionWebApi/Singletons/Singleton.cs index 5da91ad..00269ad 100644 --- a/AirPollutionWebApi/Singletons/Singleton.cs +++ b/AirPollutionWebApi/Singletons/Singleton.cs @@ -8,14 +8,19 @@ namespace AirPollutionWebApi.Singletons public class Singleton { static Singleton instance; - const string ConnectionString = "Server=tcp:forschool.database.windows.net,1433;Initial Catalog=schooldb;Persist Security Info=False;User ID=***REMOVED***;Password=***REMOVED***;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; + const string ConnectionString = "Server=tcp:forschool.database.windows.net,1433;" + + "Initial Catalog=schooldb;" + + "Persist Security Info=False;" + + "User ID=***REMOVED***;" + + "Password=***REMOVED***;" + + "MultipleActiveResultSets=False;" + + "Encrypt=True;" + + "TrustServerCertificate=False;" + + "Connection Timeout=30;"; public List<Reading> Readings = new List<Reading>(); - Singleton() - { - GetData(); - } + Singleton() {} public static Singleton Instance { @@ -29,7 +34,7 @@ namespace AirPollutionWebApi.Singletons } } - void GetData() + public void GetData() { Readings = new List<Reading>(); using (SqlConnection databaseConnection = new SqlConnection(ConnectionString)) @@ -42,10 +47,11 @@ namespace AirPollutionWebApi.Singletons { Readings.Add(new Reading { - TimeStamp = reader.GetDateTime(0), - Co = reader.GetInt32(1), - No = reader.GetInt32(2), - So = reader.GetInt32(3) + Id = reader.GetInt32(0), + TimeStamp = reader.GetInt32(1), + Co = reader.GetInt32(2), + No = reader.GetInt32(3), + So = reader.GetInt32(4) }); } } diff --git a/AirPollutionWebApi/bin/AirPollutionWebApi.dll b/AirPollutionWebApi/bin/AirPollutionWebApi.dll Binary files differindex 1a26a51..ef89550 100644 --- a/AirPollutionWebApi/bin/AirPollutionWebApi.dll +++ b/AirPollutionWebApi/bin/AirPollutionWebApi.dll diff --git a/AirPollutionWebApi/bin/AirPollutionWebApi.pdb b/AirPollutionWebApi/bin/AirPollutionWebApi.pdb Binary files differindex 1afaefb..05ea137 100644 --- a/AirPollutionWebApi/bin/AirPollutionWebApi.pdb +++ b/AirPollutionWebApi/bin/AirPollutionWebApi.pdb diff --git a/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll b/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll Binary files differindex 1a26a51..ef89550 100644 --- a/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll +++ b/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll diff --git a/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb b/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb Binary files differindex 1afaefb..05ea137 100644 --- a/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb +++ b/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb |