static public List <ZipGeoCode> GetInsideRadius(string ZipCode, string Radius) { ZipGeoCode _zipCode = GetByZip(ZipCode); Double _radius = Double.Parse(Radius); List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>(); Database db = DatabaseFactory.CreateDatabase("BKLeadsOnline"); System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_ZipGeoCodesInRadiusLoad"); db.AddInParameter(dbCommand, "Latitude", DbType.Double, _zipCode.Latitude); db.AddInParameter(dbCommand, "Longitude", DbType.Double, _zipCode.Longitude); db.AddInParameter(dbCommand, "MaxDistance", DbType.Double, _radius); using (IDataReader reader = db.ExecuteReader(dbCommand)) { while (reader.Read()) { ZipGeoCode objZipGeoCode = new ZipGeoCode(); LoadZipGeoCodeWithDistanceAndNumLeads(objZipGeoCode, reader); objZipGeoCode.IsModified = false; objZipGeoCodes.Add(objZipGeoCode); } // always call Close when done reading. reader.Close(); return(objZipGeoCodes); } }
static public List <ZipGeoCode> GetInsideRadius(double Latitude, double Longitude, double MaxDistance, DateTime?DischargeSinceDate) { List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>(); Database db = DatabaseFactory.CreateDatabase("BKLeadsOnline"); System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_ZipGeoCodesInRadiusLoad"); db.AddInParameter(dbCommand, "Latitude", DbType.Double, Latitude); db.AddInParameter(dbCommand, "Longitude", DbType.Double, Longitude); db.AddInParameter(dbCommand, "MaxDistance", DbType.Double, MaxDistance); if (DischargeSinceDate != null) { db.AddInParameter(dbCommand, "DischargeSinceDate", DbType.DateTime, DischargeSinceDate); } using (IDataReader reader = db.ExecuteReader(dbCommand)) { while (reader.Read()) { ZipGeoCode objZipGeoCode = new ZipGeoCode(); LoadZipGeoCodeWithDistanceAndNumLeads(objZipGeoCode, reader); objZipGeoCode.IsModified = false; objZipGeoCodes.Add(objZipGeoCode); } // always call Close when done reading. reader.Close(); return(objZipGeoCodes); } }
/// <summary> /// Gets the zip codes that are selected for the dealer /// </summary> /// <param name="DealerID"></param> /// <returns></returns> static public List <ZipGeoCode> GetForDealer(int DealerID) { Dealer dealer = DealerService.GetByID(DealerID); List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>(); Database db = DatabaseFactory.CreateDatabase("BKLeadsOnline"); System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_ZipGeoCodesForDealerLoad"); db.AddInParameter(dbCommand, "DealerID", DbType.Int32, dealer.ID); db.AddInParameter(dbCommand, "Latitude", DbType.Double, dealer.Latitude); db.AddInParameter(dbCommand, "Longitude", DbType.Double, dealer.Longitude); using (IDataReader reader = db.ExecuteReader(dbCommand)) { while (reader.Read()) { ZipGeoCode objZipGeoCode = new ZipGeoCode(); LoadZipGeoCodeWithDistanceAndNumLeads(objZipGeoCode, reader); objZipGeoCode.IsModified = false; objZipGeoCodes.Add(objZipGeoCode); } // always call Close when done reading. reader.Close(); return(objZipGeoCodes); } }
public ZipGeoCode Copy() { ZipGeoCode _zipGeoCode = new ZipGeoCode(); _zipGeoCode.ID = _iD; _zipGeoCode.ZipCode = _zipCode; _zipGeoCode.ZipCodeString = _zipCodeString; _zipGeoCode.City = _city; _zipGeoCode.State = _state; _zipGeoCode.County = _county; _zipGeoCode.AreaCode = _areaCode; _zipGeoCode.Latitude = _latitude; _zipGeoCode.Longitude = _longitude; return(_zipGeoCode); }
static private void LoadZipGeoCodeWithDistanceAndNumLeads(ZipGeoCode objZipGeoCode, IDataReader _reader) { if (_reader.IsDBNull(0) != true) { objZipGeoCode.ID = _reader.GetInt32(0); } if (_reader.IsDBNull(1) != true) { objZipGeoCode.ZipCode = _reader.GetInt32(1); } if (_reader.IsDBNull(2) != true) { objZipGeoCode.ZipCodeString = _reader.GetString(2); } if (_reader.IsDBNull(3) != true) { objZipGeoCode.City = _reader.GetString(3); } if (_reader.IsDBNull(4) != true) { objZipGeoCode.State = _reader.GetString(4); } if (_reader.IsDBNull(5) != true) { objZipGeoCode.County = _reader.GetString(5); } if (_reader.IsDBNull(6) != true) { objZipGeoCode.AreaCode = _reader.GetString(6); } if (_reader.IsDBNull(7) != true) { objZipGeoCode.Latitude = _reader.GetDouble(7); } if (_reader.IsDBNull(8) != true) { objZipGeoCode.Longitude = _reader.GetDouble(8); } if (_reader.IsDBNull(9) != true) { objZipGeoCode.Distance = _reader.GetDouble(9); } if (_reader.IsDBNull(10) != true) { objZipGeoCode.NumLeadsAvailable = _reader.GetInt32(10); } }
static public List <ZipGeoCode> GetAll() { List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>(); Database db = DatabaseFactory.CreateDatabase("BKLeadsOnline"); using (IDataReader reader = db.ExecuteReader(CommandType.Text, _selectViewSQL)) { while (reader.Read()) { ZipGeoCode objZipGeoCode = new ZipGeoCode(); LoadZipGeoCode(objZipGeoCode, reader); objZipGeoCode.IsModified = false; objZipGeoCodes.Add(objZipGeoCode); } // always call Close when done reading. reader.Close(); return(objZipGeoCodes); } }
static public ZipGeoCode GetByZip(string zip) { ZipGeoCode objZipGeoCode = new ZipGeoCode(); string query = _selectViewSQL + " where ZipCodeString = '" + zip + "'"; Database db = DatabaseFactory.CreateDatabase("BKLeadsOnline"); using (IDataReader reader = db.ExecuteReader(CommandType.Text, query)) { if (reader.Read()) { LoadZipGeoCode(objZipGeoCode, reader); // always call Close when done reading. reader.Close(); objZipGeoCode.IsModified = false; return(objZipGeoCode); } else { return(null); } } }