public static void Main(string[] args) { IDatabase database = new Database(conString); ITariffDao dao = new TariffDao(database); Console.Out.WriteLine(dao.FindById("A1").Name); Console.Read(); }
public Rate FindById(string tariffId, string zoneId) { Tariff tariffData = new TariffDao(database).FindById(tariffId); Zone zoneData = new ZoneDao(database).FindById(zoneId); if (tariffData == null || zoneData == null) return null; using (IDataReader reader = database.ExecuteReader(CreateFindByIdCmd(tariffId, zoneId))) { if (reader.Read()) return new Rate( tariffData, zoneData, (double)reader["PeakRate"], (double)reader["OffPeakRate"]); else return null; } }
public Rate FindById(string tariffId, string zoneId) { Tariff tariffData = new TariffDao(database).FindById(tariffId); Zone zoneData = new ZoneDao(database).FindById(zoneId); if (tariffData == null || zoneData == null) { return(null); } using (IDataReader reader = database.ExecuteReader(CreateFindByIdCmd(tariffId, zoneId))) { if (reader.Read()) { return(new Rate( tariffData, zoneData, (double)reader["PeakRate"], (double)reader["OffPeakRate"])); } else { return(null); } } }