aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2017-11-23 10:55:32 +0100
committermarcinzelent <zelent.marcin@gmail.com>2017-11-23 10:55:32 +0100
commitefc3555b0cc3ddeb0404abcbc7030627617c9719 (patch)
treec2b5c4c8cc74b37a46215e985669a2c1e1282f91 /AirPollutionWebApi
parentd5b8f7f8762cd8270a44227f23ce6f7a88ae3eac (diff)
Changed the way data is being get from database.
Diffstat (limited to 'AirPollutionWebApi')
-rw-r--r--AirPollutionWebApi/Controllers/ReadingsController.cs3
-rw-r--r--AirPollutionWebApi/Models/Reading.cs3
-rw-r--r--AirPollutionWebApi/Singletons/Singleton.cs26
-rw-r--r--AirPollutionWebApi/bin/AirPollutionWebApi.dllbin11776 -> 11776 bytes
-rw-r--r--AirPollutionWebApi/bin/AirPollutionWebApi.pdbbin2512 -> 2568 bytes
-rw-r--r--AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dllbin11776 -> 11776 bytes
-rw-r--r--AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdbbin2512 -> 2568 bytes
7 files changed, 20 insertions, 12 deletions
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
index 1a26a51..ef89550 100644
--- a/AirPollutionWebApi/bin/AirPollutionWebApi.dll
+++ b/AirPollutionWebApi/bin/AirPollutionWebApi.dll
Binary files differ
diff --git a/AirPollutionWebApi/bin/AirPollutionWebApi.pdb b/AirPollutionWebApi/bin/AirPollutionWebApi.pdb
index 1afaefb..05ea137 100644
--- a/AirPollutionWebApi/bin/AirPollutionWebApi.pdb
+++ b/AirPollutionWebApi/bin/AirPollutionWebApi.pdb
Binary files differ
diff --git a/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll b/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll
index 1a26a51..ef89550 100644
--- a/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll
+++ b/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.dll
Binary files differ
diff --git a/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb b/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb
index 1afaefb..05ea137 100644
--- a/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb
+++ b/AirPollutionWebApi/obj/Debug/AirPollutionWebApi.pdb
Binary files differ