internal List<IDepotItem> GetDepotItemsForCarrier(Enums.CarrierType carrierId) { List<IDepotItem> depot_matrix = new List<IDepotItem>(); // Only valid for TOLL at this point if (carrierId == Enums.CarrierType.TOLL) { connection.open(); depot_matrix = new List<IDepotItem>(); if (connection.open()) { string query = "SELECT suburb, state, depot, postcode, depot_code FROM ps_toll_depotcodes;"; IDataReader dataReader = connection.getDataReader(query); while (dataReader.Read()) { IDepotItem item = new TOLLDepotItem(); item.Depot = dataReader["depot"].ToString().ToUpper().Trim(); item.Postcode = Tools.normalisePostcode(dataReader["postcode"].ToString().Trim()); item.State = dataReader["state"].ToString().ToUpper().Trim(); item.Suburb = dataReader["suburb"].ToString().ToUpper().Trim(); item.DepotCode = dataReader["depot_code"].ToString().ToUpper().Trim(); depot_matrix.Add(item); } dataReader.Close(); } connection.close(); } return depot_matrix; }
internal List<IDepotItem> GetDepotItemsForCarrier(Enums.CarrierDatabaseKey carrierId) { List<IDepotItem> depot_matrix = new List<IDepotItem>(); using (BlauModel _dbcontext = BlauModel.GetContext()) { DBCarrier carrier = (from c in _dbcontext.Carrier where c.carrierId == (int)carrierId select c).FirstOrDefault(); if (carrier == default(DBCarrier)) throw new CarrierException("Carrier not found for id " + (int)carrierId); // Only valid for TOLL at this point if (carrierId == Enums.CarrierDatabaseKey.TOLL) { foreach (DBDepot depot in carrier.Depots) { IDepotItem item = new TOLLDepotItem(); item.Depot = depot.DepotName; item.Postcode = Tools.normalisePostcode(depot.Postcode); item.State = depot.State; item.Suburb = depot.Suburb; item.DepotCode = depot.DepotCode; depot_matrix.Add(item); } } } return depot_matrix; }