using Dapper; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using Traffic.Data.Models; using Traffic.Repository.Interfaces; namespace Traffic.Repository.Implements { public class TycgRepository : ITycgRepository { public IDbTransaction Transaction { get; } public IDbConnection Connection => Transaction.Connection; public TycgRepository(IDbTransaction transaction) { Transaction = transaction; } public IEnumerable GetTycgs(string tableName) { var sql = string.Empty; switch (tableName.ToLower().Trim()) { case "tycg_logases": sql = $"SELECT * FROM tycg_logases order by timestamp desc"; break; case "tycg_logbigcarviolation": sql = $"SELECT * FROM tycg_logbigcarviolation order by timestamp desc"; break; case "tycg_logchecked": sql = $"SELECT * FROM tycg_logchecked order by timestamp desc"; break; case "tycg_logcrossroad": sql = $"SELECT * FROM tycg_logcrossroad order by timestamp desc"; break; case "tycg_logmalfunctionhttp": sql = $"SELECT * FROM tycg_logmalfunctionhttp order by timestamp desc"; break; case "tycg_logrejected": sql = $"SELECT * FROM tycg_logrejected order by timestamp desc"; break; case "tycg_logtraffichttp": sql = $"SELECT * FROM tycg_logtraffichttp order by timestamp desc"; break; case "tycg_loguploaded": sql = $"SELECT * FROM tycg_loguploaded order by timestamp desc"; break; default: break; } return Connection.Query(sql, null, Transaction); } public IEnumerable GetTycgsTableName() { var sql = $"SELECT * FROM {nameof(Log_Mapping)}"; return Connection.Query(sql, null, Transaction); } } }