Update CustomerView class properties to match the columns being selected out of the database.

Remove 'static' from all functions under SqliteDataAccess class.
Write correct SQL Query for LoadCustomerView.
This commit is contained in:
kougyoku 2019-10-11 21:30:25 -07:00
parent d6d3e0ca0d
commit 58006f2955

View File

@ -12,9 +12,9 @@ namespace QueueSys
{
public class CustomerView
{
public string customerName { get; }
public string status { get; }
public string timeElapsed { get; }
public string Customer { get; }
public string Status { get; }
public string TimeElapsed { get; }
}
public class EmployeeView
@ -28,7 +28,7 @@ namespace QueueSys
public class SqliteDataAccess
{
public static List<EmployeeView> LoadEmployeeView()
public List<EmployeeView> LoadEmployeeView()
{
//A using statement protects us as a failsafe: it guarantees the connection to the
//database will be closed, even in event of an application or computer crash.
@ -41,18 +41,18 @@ namespace QueueSys
}
}
public static List<CustomerView> LoadCustomerView()
public List<CustomerView> LoadCustomerView()
{
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{
string strQuery = "SELECT customer_name,status FROM active_customers;";
string strQuery = "SELECT customer_name as Customer,status_lookup.status as Status,Cast ((JulianDay('now') - JulianDay(start_time)) * 24 * 60 As Integer) as TimeElapsed FROM active_customers INNER JOIN status_lookup on active_customers.status_id=status_lookup.status_id ORDER BY active_customers.status_id";
var output = cnn.Query<CustomerView>(strQuery, new DynamicParameters());
return output.ToList();
}
}
public static void SaveCustomer(EmployeeView customer)
public void SaveCustomer(EmployeeView customer)
{
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{
@ -61,7 +61,7 @@ namespace QueueSys
}
}
public static void ArchiveCustomer(EmployeeView customer)
public void ArchiveCustomer(EmployeeView customer)
{
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{