66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
using Dapper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.SQLite;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace QueueSys
|
|
{
|
|
public class CustomerView
|
|
{
|
|
public string customerName { get; }
|
|
public string status { get; }
|
|
public string timeElapsed { get; }
|
|
}
|
|
|
|
public class EmployeeView
|
|
{
|
|
public int id { get; }
|
|
public string customer_name { get; set; }
|
|
public int num_bags { get; set; }
|
|
public string employee { get; set; }
|
|
public string status { get; set; }
|
|
}
|
|
|
|
public class SqliteDataAccess
|
|
{
|
|
public static List<EmployeeView> LoadEmployeeView()
|
|
{
|
|
string strQuery = "SELECT id,customer_name,num_bags,employee,status FROM active_customers;";
|
|
|
|
//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.
|
|
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
|
{
|
|
var output = cnn.Query<EmployeeView>(strQuery, new DynamicParameters());
|
|
return output.ToList();
|
|
}
|
|
}
|
|
|
|
public static List<CustomerView> LoadCustomerView()
|
|
{
|
|
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
|
{
|
|
string strQuery = "SELECT customer_name,status FROM active_customers;";
|
|
|
|
var output = cnn.Query<CustomerView>(strQuery, new DynamicParameters());
|
|
return output.ToList();
|
|
}
|
|
}
|
|
|
|
public static void SaveCustomer(EmployeeView customer)
|
|
{
|
|
|
|
}
|
|
|
|
private static string LoadConnectionString(string id="Default")
|
|
{
|
|
return ConfigurationManager.ConnectionStrings[id].ConnectionString;
|
|
}
|
|
}
|
|
}
|