///<summary>Inserts one ZipCode into the database. Returns the new priKey.</summary> internal static long Insert(ZipCode zipCode) { if(DataConnection.DBtype==DatabaseType.Oracle) { zipCode.ZipCodeNum=DbHelper.GetNextOracleKey("zipcode","ZipCodeNum"); int loopcount=0; while(loopcount<100){ try { return Insert(zipCode,true); } catch(Oracle.DataAccess.Client.OracleException ex){ if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){ zipCode.ZipCodeNum++; loopcount++; } else{ throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return Insert(zipCode,false); } }
///<summary>Inserts one ZipCode into the database. Provides option to use the existing priKey.</summary> public static long Insert(ZipCode zipCode,bool useExistingPK){ if(!useExistingPK && PrefC.RandomKeys) { zipCode.ZipCodeNum=ReplicationServers.GetKey("zipcode","ZipCodeNum"); } string command="INSERT INTO zipcode ("; if(useExistingPK || PrefC.RandomKeys) { command+="ZipCodeNum,"; } command+="ZipCodeDigits,City,State,IsFrequent) VALUES("; if(useExistingPK || PrefC.RandomKeys) { command+=POut.Long(zipCode.ZipCodeNum)+","; } command+= "'"+POut.String(zipCode.ZipCodeDigits)+"'," +"'"+POut.String(zipCode.City)+"'," +"'"+POut.String(zipCode.State)+"'," + POut.Bool (zipCode.IsFrequent)+")"; if(useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { zipCode.ZipCodeNum=Db.NonQ(command,true); } return zipCode.ZipCodeNum; }
///<summary>Converts a DataTable to a list of objects.</summary> public static List<ZipCode> TableToList(DataTable table){ List<ZipCode> retVal=new List<ZipCode>(); ZipCode zipCode; for(int i=0;i<table.Rows.Count;i++) { zipCode=new ZipCode(); zipCode.ZipCodeNum = PIn.Long (table.Rows[i]["ZipCodeNum"].ToString()); zipCode.ZipCodeDigits= PIn.String(table.Rows[i]["ZipCodeDigits"].ToString()); zipCode.City = PIn.String(table.Rows[i]["City"].ToString()); zipCode.State = PIn.String(table.Rows[i]["State"].ToString()); zipCode.IsFrequent = PIn.Bool (table.Rows[i]["IsFrequent"].ToString()); retVal.Add(zipCode); } return retVal; }
private void ImportZipData(ZipData data) { //foreach (var data in zipData) //{ var state = string.IsNullOrEmpty(data.StateCode) ? null : _stateRepository.GetStatebyCode(data.StateCode); if (state != null) { var city = _cityRepository.GetCityByStateAndName(state.Id, data.City); if (city == null) { city = new City() { Name = data.City, CityCode = "", Description = "Created while importing Zip from External Source.", StateId = state.Id }; city = _cityRepository.Save(city); } ZipCode zip = null; try { zip = _zipCodeRepository.GetZipCode(data.ZipCode, city.Id); if (zip == null) { zip = new ZipCode { CityId = city.Id, Zip = data.ZipCode }; } } catch (ObjectNotFoundInPersistenceException <ZipCode> ) { zip = new ZipCode { CityId = city.Id, Zip = data.ZipCode }; } if (zip.Id <= 0) { PrepareZipObject(data.Latitude, data.Longitude, data.TimeZone, data.DayLightSaving, zip); _zipCodeRepository.Save(zip); } } //} }
public void FillForm(FormModel user) { FirstNameField.SendKeys(user.FirstName); LastNameField.SendKeys(user.LastName); PasswordField.SendKeys(user.PasswordField); Address1.SendKeys(user.Address1); City.SendKeys(user.City); State.Click(); SelectElement stateValue = new SelectElement(State); stateValue.SelectByIndex(user.State); ZipCode.SendKeys(user.ZipCode.ToString()); MobilePhone.SendKeys(user.MobilePhone.ToString()); AssignAnAddresAlias.SendKeys(user.AssignAnAddresAlias); ScroolTo(RegisterButton).Click(); }
/// <summary> /// This method inserts a 'ZipCode' object. /// </summary> /// <param name='List<PolymorphicObject>'>The 'ZipCode' to insert. /// <returns>A PolymorphicObject object with a Boolean value. internal PolymorphicObject InsertZipCode(List <PolymorphicObject> parameters, DataConnector dataConnector) { // Initial Value PolymorphicObject returnObject = new PolymorphicObject(); // locals ZipCode zipCode = null; // If the data connection is connected if ((dataConnector != null) && (dataConnector.Connected == true)) { // Create Insert StoredProcedure InsertZipCodeStoredProcedure insertZipCodeProc = null; // verify the first parameters is a(n) 'ZipCode'. if (parameters[0].ObjectValue as ZipCode != null) { // Create ZipCode Parameter zipCode = (ZipCode)parameters[0].ObjectValue; // verify zipCode exists if (zipCode != null) { // Now create insertZipCodeProc from ZipCodeWriter // The DataWriter converts the 'ZipCode' // to the SqlParameter[] array needed to insert a 'ZipCode'. insertZipCodeProc = ZipCodeWriter.CreateInsertZipCodeStoredProcedure(zipCode); } // Verify insertZipCodeProc exists if (insertZipCodeProc != null) { // Execute Insert Stored Procedure returnObject.IntegerValue = this.DataManager.ZipCodeManager.InsertZipCode(insertZipCodeProc, dataConnector); } } else { // Raise Error Data Connection Not Available throw new Exception("The database connection is not available."); } } // return value return(returnObject); }
static void Main() { ZipCode zipCode = new ZipCode(); zipCode.FiveDigitCode = 0; zipCode.PlusFourExtension = 0; //ZipCode zipcode1 = zipCode; //zipCode.FiveDigitCode = 33; Console.WriteLine(zipCode.FiveDigitCode); Console.WriteLine(zipCode.PlusFourExtension); Console.WriteLine(zipCode.FiveDigitCode); // Delay. Console.ReadKey(); }
public ZipCodeData GetZipInfo(string zip) { ZipCodeData zipCodeData = null; IZipCodeRepository zipCodeRepository = _zipCodeRepository ?? new ZipCodeRepository(); ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zip); if (zipCodeEntity != null) { zipCodeData = new ZipCodeData { City = zipCodeEntity.City, State = zipCodeEntity.State.Abbreviation, ZipCode = zipCodeEntity.Zip }; } return(zipCodeData); }
public Restaurant ToRestaurant() { Restaurant restaurant = new Restaurant(); restaurant.Id = Id; restaurant.Name = Name; restaurant.Address = Address; restaurant.ZipCode = ZipCode.ToUpper(); restaurant.Phone = Phone; restaurant.Website = Website; restaurant.Cuisine_Id = Cuisine_Id; restaurant.PriceRange_Id = PriceRange_Id; restaurant.BYOW = BYOW; restaurant.Rating = Rating; restaurant.Logo_Id = Logo_Id; return(restaurant); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <ZipCode> TableToList(DataTable table) { List <ZipCode> retVal = new List <ZipCode>(); ZipCode zipCode; foreach (DataRow row in table.Rows) { zipCode = new ZipCode(); zipCode.ZipCodeNum = PIn.Long(row["ZipCodeNum"].ToString()); zipCode.ZipCodeDigits = PIn.String(row["ZipCodeDigits"].ToString()); zipCode.City = PIn.String(row["City"].ToString()); zipCode.State = PIn.String(row["State"].ToString()); zipCode.IsFrequent = PIn.Bool(row["IsFrequent"].ToString()); retVal.Add(zipCode); } return(retVal); }
public UpdateUserDataViewModel ToUpdateDataViewModel(User user, ZipCode zipCode) { var model = new UpdateUserDataViewModel { User = user, FirstName = user.FirstName, LastName = user.LastName, Address = user.Address, ZipCode4 = zipCode.ZipCode4, ZipCode3 = zipCode.ZipCode3, City = user.City, TaxPayerNumber = user.TaxPayerNumber, PhoneNumber = user.PhoneNumber, }; return(model); }
public async Task <IActionResult> OnGetAsync(int?id) { _logger.LogDebug($"ZipCodes/Edit/OnGetAsync({ id })"); if (id == null) { return(NotFound()); } ZipCode = await _context.ZipCode.FindAsync(id).ConfigureAwait(false); if (ZipCode == null) { return(NotFound()); } return(Page()); }
public void FillForm(RegistrationUser user) { RadioButtons[1].Click(); CutomerFirstName.SendKeys(user.FirstName); CutomerLastName.SendKeys(user.LastName); CustomerPassword.SendKeys(user.Password); Date.SelectByValue(user.Date); Month.SelectByValue(user.Month); Year.SelectByValue(user.Year); Address.SendKeys(user.Address); City.SendKeys(user.City); State.SelectByText(user.State); ZipCode.SendKeys(user.PostCode); Phone.SendKeys(user.Phone); AddressAlias.SendKeys(user.Alias); //alias.Type("Maria") ??? RegisterButton.Click(); }
/// <summary> /// This method creates the parameter for a 'ZipCode' data operation. /// </summary> /// <param name='zipcode'>The 'ZipCode' to use as the first /// parameter (parameters[0]).</param> /// <returns>A List<PolymorphicObject> collection.</returns> private List <PolymorphicObject> CreateZipCodeParameter(ZipCode zipCode) { // Initial Value List <PolymorphicObject> parameters = new List <PolymorphicObject>(); // Create PolymorphicObject to hold the parameter PolymorphicObject parameter = new PolymorphicObject(); // Set parameter.ObjectValue parameter.ObjectValue = zipCode; // Add userParameter to parameters parameters.Add(parameter); // return value return(parameters); }
///<summary>Converts a DataTable to a list of objects.</summary> internal static List <ZipCode> TableToList(DataTable table) { List <ZipCode> retVal = new List <ZipCode>(); ZipCode zipCode; for (int i = 0; i < table.Rows.Count; i++) { zipCode = new ZipCode(); zipCode.ZipCodeNum = PIn.Long(table.Rows[i]["ZipCodeNum"].ToString()); zipCode.ZipCodeDigits = PIn.String(table.Rows[i]["ZipCodeDigits"].ToString()); zipCode.City = PIn.String(table.Rows[i]["City"].ToString()); zipCode.State = PIn.String(table.Rows[i]["State"].ToString()); zipCode.IsFrequent = PIn.Bool(table.Rows[i]["IsFrequent"].ToString()); retVal.Add(zipCode); } return(retVal); }
public ActionResult CheckZipCode(string code) { ZipCode zipcode = zipCodeRepository.GetByCode(code); if (zipcode != null) { return(Json(new { Exist = true })); } return(Json(new { Exist = false, ZipCode = HttpUtility.HtmlEncode(code) })); }
public string CreateZipCode(ZipCode zipCode) { Models.zip_code zip = new zip_code(); zip.zip_code1 = zipCode.Zip; zip.city = zipCode.City; db.zip_codes.InsertOnSubmit(zip); try { db.SubmitChanges(); return("Ny zip code oprettet: " + zip.zip_code1); } catch (Exception e) { return("Oprettelsen af ny zip mislykkedes. Kontakt IT-support med følgende fejlkode: " + e.Message); } }
public ZipCodeData GetZipInfo(string zip) { ZipCodeData zipCodeData = null; string hostIdentity = WindowsIdentity.GetCurrent().Name; //string primaryIdentity = ServiceSecurityContext.Current.PrimaryIdentity.Name; //string windowsIdentity = ServiceSecurityContext.Current.WindowsIdentity.Name; //string threadIdentity = Thread.CurrentPrincipal.Identity.Name; IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository(); ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zip); if (zipCodeEntity != null) { zipCodeData = new ZipCodeData() { City = zipCodeEntity.City, State = zipCodeEntity.State.Abbreviation, ZipCode = zipCodeEntity.Zip }; } else { //throw new ApplicationException($"Zip code {zip} not found."); //throw new FaultException($"Zip code {zip} not found."); //ApplicationException ex = new ApplicationException($"Zip code {zip} not found."); //throw new FaultException<ApplicationException>(ex, "Just another message"); NotFoundData data = new NotFoundData() { Message = $"Zip code {zip} not found.", When = DateTime.Now.ToString(), User = "******" }; throw new FaultException <NotFoundData>(data, "Just another message"); } _Counter++; //Console.WriteLine($"Counter = {_Counter.ToString()}"); //Thread.Sleep(10000); //MessageBox.Show($"{zip} = {zipCodeData.City}, {zipCodeData.State}", "Call Counter " + _Counter); return(zipCodeData); }
///<summary>Updates one ZipCode in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(ZipCode zipCode, ZipCode oldZipCode) { string command = ""; if (zipCode.ZipCodeDigits != oldZipCode.ZipCodeDigits) { if (command != "") { command += ","; } command += "ZipCodeDigits = '" + POut.String(zipCode.ZipCodeDigits) + "'"; } if (zipCode.City != oldZipCode.City) { if (command != "") { command += ","; } command += "City = '" + POut.String(zipCode.City) + "'"; } if (zipCode.State != oldZipCode.State) { if (command != "") { command += ","; } command += "State = '" + POut.String(zipCode.State) + "'"; } if (zipCode.IsFrequent != oldZipCode.IsFrequent) { if (command != "") { command += ","; } command += "IsFrequent = " + POut.Bool(zipCode.IsFrequent) + ""; } if (command == "") { return(false); } command = "UPDATE zipcode SET " + command + " WHERE ZipCodeNum = " + POut.Long(zipCode.ZipCodeNum); Db.NonQ(command); return(true); }
/// <summary> /// Ons the get async. /// </summary> /// <returns>The get async.</returns> /// <param name="id">Identifier.</param> public async Task <IActionResult> OnGetAsync(int?id) { _logger.LogDebug($"ZipCodes/Details/OnGetAsync ({ id })"); if (id == null) { return(NotFound()); } ZipCode = await _context.ZipCode.SingleOrDefaultAsync(m => m.ID == id).ConfigureAwait(false); if (ZipCode == null) { return(NotFound()); } return(Page()); }
public override int GetHashCode() { unchecked { var hashCode = (CompanyName != null ? CompanyName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ContactFirstName != null ? ContactFirstName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ContactLastName != null ? ContactLastName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ContactFullName != null ? ContactFullName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Address != null ? Address.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (State != null ? State.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ZipCode != null ? ZipCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Country != null ? Country.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Phone != null ? Phone.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Email != null ? Email.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Method used to get city name with a zip code /// </summary> /// <param name="zip">A valid zip code in Denmark</param> /// <returns>Returns the city name matching the zip code</returns> public static string GetCity(int zip) { try { WebClient client = new WebClient(); client.Encoding = Encoding.UTF8; var downloadedString = client.DownloadString($"https://dawa.aws.dk/postnumre/{zip}"); //Matcing the dowloaded json string with class ZipCode ZipCode r = JsonConvert.DeserializeObject <ZipCode>(downloadedString); return(r.navn); } catch (Exception e) { Console.WriteLine(e); return(null); } }
/// <summary> /// This method creates the sql Parameter[] array /// that holds the primary key value. /// </summary> /// <param name='zipCode'>The 'ZipCode' to get the primary key of.</param> /// <returns>A SqlParameter[] array which contains the primary key value. /// to delete.</returns> internal static SqlParameter[] CreatePrimaryKeyParameter(ZipCode zipCode) { // Initial Value SqlParameter[] parameters = new SqlParameter[1]; // verify user exists if (zipCode != null) { // Create PrimaryKey Parameter SqlParameter @Id = new SqlParameter("@Id", zipCode.Id); // Set parameters[0] to @Id parameters[0] = @Id; } // return value return(parameters); }
/// <summary> /// This method creates an instance of a /// 'FindZipCodeStoredProcedure' object and /// creates the sql parameter[] array needed /// to execute the procedure 'ZipCode_Find'. /// </summary> /// <param name="zipCode">The 'ZipCode' to use to /// get the primary key parameter.</param> /// <returns>An instance of an FetchUserStoredProcedure</returns> public static FindZipCodeStoredProcedure CreateFindZipCodeStoredProcedure(ZipCode zipCode) { // Initial Value FindZipCodeStoredProcedure findZipCodeStoredProcedure = null; // verify zipCode exists if (zipCode != null) { // Instanciate findZipCodeStoredProcedure findZipCodeStoredProcedure = new FindZipCodeStoredProcedure(); // Now create parameters for this procedure findZipCodeStoredProcedure.Parameters = CreatePrimaryKeyParameter(zipCode); } // return value return(findZipCodeStoredProcedure); }
//private Location SaveCooridnate(string postalCode ) //{ // var coordinate = GetCoordinate(postalCode); // if (coordinate != null && coordinate.Latitude != null && coordinate.Longitude != null) // return coordinate; // var locationLatLong = this.GetAll()?.FirstOrDefault(x => x.Name.EqualsIgnoreCase(postalCode) && x.Latitude != null && x.Longitude != null); // if (locationLatLong != null) // { // //todo add as coordinate // return locationLatLong; // } // //todo Get lat and long // //then update or insert // var location = this.GetAll()?.FirstOrDefault(x => x.Name.EqualsIgnoreCase(postalCode)); // if (location == null) // { //add as coordinate // } // if (ConfigurationManager.AppSettings["google.maps.requestperday"] != null) // _apiRequestsPerDay = ConfigurationManager.AppSettings["google.maps.requestperday"].ToString().ConvertTo<int>(); // if (ConfigurationManager.AppSettings["google.maps.requestpersecond"] != null) // _apiRequestsPerSecond = ConfigurationManager.AppSettings["google.maps.requestpersecond"].ToString().ConvertTo<int>(); // // if (geos.Count > _apiRequestsPerDay) // // geos = geos.Take(_apiRequestsPerDay).ToList(); // long totalElapsedTime = 0; // int millisecondCap = 1000; //or 1 second. // //If we go below this time on all the requests then we'll go over the throttle limit. // int minRequesTimeThreshold = millisecondCap / _apiRequestsPerSecond; // Stopwatch stopwatch = new Stopwatch(); // int index = 1; // var address = this.GetFullAddress(location); //location.Address1 + " " + location.City + " " + location.State + " " + location.Postal; // //location.Name = address; // //var requestUri = string.Format("https://maps.googleapis.com/maps/api/geocode/xml?key=YOURGOOGLEAPIKEY&address={0}&sensor=false", Uri.EscapeDataString(address)); // var requestUri = string.Format("https://maps.googleapis.com/maps/api/geocode/xml?key=YOURGOOGLEAPIKEY&address={0}&sensor=false", Uri.EscapeDataString(address)); // stopwatch.Restart(); // Begin timing. // var request = WebRequest.Create(requestUri); // var response = request.GetResponse(); // var xdoc = XDocument.Load(response.GetResponseStream()); // // var xdoc = XDocument.Parse(_googleGeoXml); //test parse // var status = xdoc.Element("GeocodeResponse").Element("status"); // switch (status.Value) // { // case GoogleGeo.ResponseStatus.OK: // // location.DescriptionEx = xdoc.ToString(); // var result = xdoc.Element("GeocodeResponse").Element("result"); // var locationElement = result.Element("geometry").Element("location"); // location.Latitude = locationElement.Element("lat").Value.ConvertTo<float>(); // location.Longitude = locationElement.Element("lng").Value.ConvertTo<float>(); // //DataQuery dqFC = new DataQuery(); // // dqFC.SQL = string.Format("UPDATE FireDeptIncidents SET Latitude={0}, Longitude={1} WHERE inci_id='{2}'", location.Latitude, location.Longitude, location.inci_id); // // int res = fim.Update(dqFC); // // SetProgressBar(index, "updated:" + address); // break; // case GoogleGeo.ResponseStatus.OverLimit: // //SetProgressBar(-1, "Status: OverLimit"); // //todo log this // return null; // case GoogleGeo.ResponseStatus.Denied: // //todo log this // // SetProgressBar(-1, "Status: Denied"); // //SetProgressBar(0, xdoc.ToString()); // return null; // } // // Stop timing. // stopwatch.Stop(); // long elapsedTime = stopwatch.ElapsedMilliseconds;//How long it took to get and process the response. // if (elapsedTime < minRequesTimeThreshold) // { // //SetProgressBar(-1, "suspending for:" + (minRequesTimeThreshold - (int)elapsedTime).ToString()); // Thread.Sleep(minRequesTimeThreshold - (int)elapsedTime);//sleep is in milliseconds // totalElapsedTime += elapsedTime; // // millisecond = .001 or 10−3 or 1 / 1000 // //so 1 request every 100 milliseconds // } //} //public void ImportZipCodes(string pathToFile) { // ZipCodes codes = LoadZipCodeCoordinates(pathToFile); // foreach (int zipCode in codes.Keys) // { // ZipCode loc = codes[zipCode]; // SaveCooridnate(loc.Code.ToString(), loc.State, loc.Latitude, loc.Longitude); // } // return; //} // Columns 1-2: United States Postal Service State Abbreviation // Columns 3-66: Name (e.g. 35004 5-Digit ZCTA - there are no post office names) // Columns 67-75: Total Population (2000) // Columns 76-84: Total Housing Units (2000) // Columns 85-98: Land Area (square meters) - Created for statistical purposes only. // Columns 99-112: Water Area (square meters) - Created for statistical purposes only. // Columns 113-124: Land Area (square miles) - Created for statistical purposes only. // Columns 125-136: Water Area (square miles) - Created for statistical purposes only. // Columns 137-146: Latitude (decimal degrees) First character is blank or "-" denoting North or South latitude respectively // Columns 147-157: Longitude (decimal degrees) First character is blank or "-" denoting East or West longitude respectively private ZipCodes LoadZipCodeCoordinates(string pathToFile) { ZipCodes codes = new ZipCodes(); string[] fileLines = File.ReadAllLines(pathToFile); string sep = "\t"; foreach (string line in fileLines) { if (string.IsNullOrWhiteSpace(line)) { continue; } string code = ""; //int double lat = 0; double lon = 0; string[] tokens = line.Split(sep.ToCharArray()); //if (!Int32.TryParse(line.Substring(2, 5), out code) || // !double.TryParse(line.Substring(136, 10), out lat) || // !double.TryParse(line.Substring(146, 10), out lon)) // continue;// skip lines that aren't valid if ( //!Int32.TryParse(tokens[0], out code) || !double.TryParse(tokens[5], out lat) || !double.TryParse(tokens[6], out lon)) { continue;// skip lines that aren't valid } if (codes.ContainsKey(code)) { continue; // there are a few duplicates due to state boundaries, ignore them } codes.Add(code, new ZipCode() { // State = line.Substring(0, 2), Code = code, Latitude = ZipCode.ToRadians(lat), Longitude = ZipCode.ToRadians(lon), }); } return(codes); }
public void Update(string name, string street, int number, string neighborhood, string city, string state, string country, string zipCode) { if (!string.IsNullOrEmpty(name) && !Name.Equals(name)) { Name = name; } if (!string.IsNullOrEmpty(street) && !Street.Equals(street)) { Street = street; } if (number > 0) { Number = number; } if (!string.IsNullOrEmpty(neighborhood) && !Neighborhood.Equals(neighborhood)) { Neighborhood = neighborhood; } if (!string.IsNullOrEmpty(city) && !City.Equals(city)) { City = city; } if (!string.IsNullOrEmpty(state) && !State.Equals(state)) { State = state; } if (!string.IsNullOrEmpty(country) && !Country.Equals(country)) { Country = country; } if (!string.IsNullOrEmpty(zipCode) && !ZipCode.Equals(zipCode)) { ZipCode = zipCode; } Updated = DateTime.Now; }
public Schema() : base() { InstanceType = typeof(__Frtransact__); Properties.ClearExposed(); City = Add<__TString__>("City$"); City.DefaultValue = ""; City.Editable = true; City.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__City__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__City__ = (System.String)_v_; }, false); Country = Add<__TString__>("Country$"); Country.DefaultValue = ""; Country.Editable = true; Country.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Country__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Country__ = (System.String)_v_; }, false); Name = Add<__TString__>("Name$"); Name.DefaultValue = ""; Name.Editable = true; Name.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Name__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Name__ = (System.String)_v_; }, false); Number = Add<__TString__>("Number$"); Number.DefaultValue = ""; Number.Editable = true; Number.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Number__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Number__ = (System.String)_v_; }, false); Street = Add<__TString__>("Street$"); Street.DefaultValue = ""; Street.Editable = true; Street.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Street__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Street__ = (System.String)_v_; }, false); ZipCode = Add<__TString__>("ZipCode$"); ZipCode.DefaultValue = ""; ZipCode.Editable = true; ZipCode.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__ZipCode__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__ZipCode__ = (System.String)_v_; }, false); Date = Add<__TString__>("Date$"); Date.DefaultValue = ""; Date.Editable = true; Date.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Date__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Date__ = (System.String)_v_; }, false); SalesPrice = Add<__TLong__>("SalesPrice$"); SalesPrice.DefaultValue = 0L; SalesPrice.Editable = true; SalesPrice.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__SalesPrice__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__SalesPrice__ = (System.Int64)_v_; }, false); Commission = Add<__TLong__>("Commission$"); Commission.DefaultValue = 0L; Commission.Editable = true; Commission.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Commission__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Commission__ = (System.Int64)_v_; }, false); Address = Add<__TString__>("Address"); Address.DefaultValue = ""; Address.SetCustomAccessors((_p_) => { return ((__Frtransact__)_p_).__bf__Address__; }, (_p_, _v_) => { ((__Frtransact__)_p_).__bf__Address__ = (System.String)_v_; }, false); }
/// <summary> /// Finds a 'ZipCode' object by the primary key. /// This method used the DataBridgeManager to execute the 'Find' using the /// procedure 'ZipCode_Find'</param> /// </summary> /// <param name='tempZipCode'>A temporary ZipCode for passing values.</param> /// <returns>A 'ZipCode' object if found else a null 'ZipCode'.</returns> public ZipCode Find(ZipCode tempZipCode) { // Initial values ZipCode zipCode = null; // Get information for calling 'DataBridgeManager.PerformDataOperation' method. string methodName = "Find"; string objectName = "ApplicationLogicComponent.Controllers"; try { // If object exists if (tempZipCode != null) { // Create DataOperation ApplicationController.DataOperationMethod findMethod = this.AppController.DataBridge.DataOperations.ZipCodeMethods.FindZipCode; // Create parameters for this method List <PolymorphicObject> parameters = CreateZipCodeParameter(tempZipCode); // Perform DataOperation PolymorphicObject returnObject = this.AppController.DataBridge.PerformDataOperation(methodName, objectName, findMethod, parameters); // If return object exists if ((returnObject != null) && (returnObject.ObjectValue as ZipCode != null)) { // Get ReturnObject zipCode = (ZipCode)returnObject.ObjectValue; } } } catch (Exception error) { // If ErrorProcessor exists if (this.ErrorProcessor != null) { // Log the current error this.ErrorProcessor.LogError(methodName, objectName, error); } } // return value return(zipCode); }
public Schema() : base() { InstanceType = typeof(__Franchis__); Properties.ClearExposed(); Html = Add <__TString__>("Html"); Html.DefaultValue = "/tatiana/FranchiseOfficeEditPage.html"; Html.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Html__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Html__ = (System.String)_v_; }, false); Name = Add <__TString__>("Name$"); Name.DefaultValue = ""; Name.Editable = true; Name.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Name__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Name__ = (System.String)_v_; }, false); Street = Add <__TString__>("Street$"); Street.DefaultValue = ""; Street.Editable = true; Street.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Street__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Street__ = (System.String)_v_; }, false); Number = Add <__TLong__>("Number$"); Number.DefaultValue = 0L; Number.Editable = true; Number.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Number__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Number__ = (System.Int64)_v_; }, false); ZipCode = Add <__TLong__>("ZipCode$"); ZipCode.DefaultValue = 0L; ZipCode.Editable = true; ZipCode.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__ZipCode__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__ZipCode__ = (System.Int64)_v_; }, false); City = Add <__TString__>("City$"); City.DefaultValue = ""; City.Editable = true; City.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__City__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__City__ = (System.String)_v_; }, false); Country = Add <__TString__>("Country$"); Country.DefaultValue = ""; Country.Editable = true; Country.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__Country__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__Country__ = (System.String)_v_; }, false); SaveTrigger = Add <__TLong__>("SaveTrigger$"); SaveTrigger.DefaultValue = 0L; SaveTrigger.Editable = true; SaveTrigger.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__SaveTrigger__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__SaveTrigger__ = (System.Int64)_v_; }, false); SaveTrigger.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.SaveTrigger() { App = (FranchiseOfficeEditPage)pup, Template = (TLong)prop, Value = value }); }, (Json pup, Starcounter.Input <Int64> input) => { ((FranchiseOfficeEditPage)pup).Handle((Input.SaveTrigger)input); }); FullAddress = Add <__TString__>("FullAddress", bind: "FullAddress"); FullAddress.DefaultValue = ""; FullAddress.SetCustomAccessors((_p_) => { return(((__Franchis__)_p_).__bf__FullAddress__); }, (_p_, _v_) => { ((__Franchis__)_p_).__bf__FullAddress__ = (System.String)_v_; }, false); }
public bool Delete(RegionModel Region) { using (RegionEntities re = new RegionEntities()) { try { Region r = re.Regions.Single(reg => reg.ID == Region.ID); ZipCode z = re.ZipCodes.Single(zip => zip.ID == Region.ID); re.Regions.Remove(r); re.ZipCodes.Remove(z); re.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public void Validate() { if (StreetName.IsNullOrEmpty()) { throw new AddressInvalidException("StreetName should not be null or empty"); } if (City.IsNullOrEmpty()) { throw new AddressInvalidException("city should not be null or empty"); } if (ZipCode.IsNullOrEmpty()) { throw new AddressInvalidException("zipCode should not be null or empty"); } if (Country.IsNullOrEmpty()) { throw new AddressInvalidException("country should not be null or empty"); } }
public IEnumerable <ZipCodeData> GetZips(string zip, int range) { List <ZipCodeData> zipCodeData = new List <ZipCodeData>(); IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository(); ZipCode zipEntity = zipCodeRepository.GetByZip(zip); var zips = zipCodeRepository.GetZipsForRange(zipEntity, range); if (zips != null) { foreach (ZipCode zipCode in zips) { zipCodeData.Add(LocalConfiguration.Mapper.Map <ZipCodeData>(zipCode)); } } return(zipCodeData); }
public void UpdateZipCity(IEnumerable <ZipCityData> zipCityData) { IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository(); foreach (ZipCityData zipCityItem in zipCityData) { ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zipCityItem.ZipCode); zipCodeEntity.City = zipCityItem.City; ZipCode updatedItem = zipCodeRepository.Update(zipCodeEntity); IUpdateZipCallback callback = OperationContext.Current.GetCallbackChannel <IUpdateZipCallback>(); if (callback != null) { callback.ZipUpdated(zipCityItem); } } }
private void textZip_Validating(object sender, System.ComponentModel.CancelEventArgs e) { //fired as soon as control loses focus. //it's here to validate if zip is typed in to text box instead of picked from list. //if(textZip.Text=="" && (textCity.Text!="" || textState.Text!="")){ // if(MessageBox.Show(Lan.g(this,"Delete the City and State?"),"",MessageBoxButtons.OKCancel) // ==DialogResult.OK){ // textCity.Text=""; // textState.Text=""; // } // return; //} if(textZip.Text.Length<5){ return; } if(comboZip.SelectedIndex!=-1){ return; } //the autofill only works if both city and state are left blank if(textCity.Text!="" || textState.Text!=""){ return; } ZipCodes.GetALMatches(textZip.Text); if(ZipCodes.ALMatches.Count==0){ //No match found. Must enter info for new zipcode ZipCode ZipCodeCur=new ZipCode(); ZipCodeCur.ZipCodeDigits=textZip.Text; FormZipCodeEdit FormZE=new FormZipCodeEdit(); FormZE.ZipCodeCur=ZipCodeCur; FormZE.IsNew=true; FormZE.ShowDialog(); if(FormZE.DialogResult!=DialogResult.OK){ return; } DataValid.SetInvalid(InvalidType.ZipCodes);//FormZipCodeEdit does not contain internal refresh FillComboZip(); textCity.Text=ZipCodeCur.City; textState.Text=ZipCodeCur.State; textZip.Text=ZipCodeCur.ZipCodeDigits; } else if(ZipCodes.ALMatches.Count==1){ //only one match found. Use it. textCity.Text=((ZipCode)ZipCodes.ALMatches[0]).City; textState.Text=((ZipCode)ZipCodes.ALMatches[0]).State; } else{ //multiple matches found. Pick one FormZipSelect FormZS=new FormZipSelect(); FormZS.ShowDialog(); FillComboZip(); if(FormZS.DialogResult!=DialogResult.OK){ return; } DataValid.SetInvalid(InvalidType.ZipCodes); textCity.Text=FormZS.ZipSelected.City; textState.Text=FormZS.ZipSelected.State; textZip.Text=FormZS.ZipSelected.ZipCodeDigits; } }
partial void OnZipCodeChanging(ZipCode value);
/// <summary> /// Create a new AddressInfo object. /// </summary> /// <param name="zipCode">Initial value of ZipCode.</param> public static AddressInfo CreateAddressInfo(ZipCode zipCode) { AddressInfo addressInfo = new AddressInfo(); if ((zipCode == null)) { throw new global::System.ArgumentNullException("zipCode"); } addressInfo.ZipCode = zipCode; return addressInfo; }
private ZipCode DefaultValues(ZipCode row) { return row; }
internal Coordinate(ZipCode zip, double latitude, double longitude) { Zip = zip; Latitude = latitude; Longitude = longitude; }
///<summary>Updates one ZipCode in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(ZipCode zipCode,ZipCode oldZipCode){ string command=""; if(zipCode.ZipCodeDigits != oldZipCode.ZipCodeDigits) { if(command!=""){ command+=",";} command+="ZipCodeDigits = '"+POut.String(zipCode.ZipCodeDigits)+"'"; } if(zipCode.City != oldZipCode.City) { if(command!=""){ command+=",";} command+="City = '"+POut.String(zipCode.City)+"'"; } if(zipCode.State != oldZipCode.State) { if(command!=""){ command+=",";} command+="State = '"+POut.String(zipCode.State)+"'"; } if(zipCode.IsFrequent != oldZipCode.IsFrequent) { if(command!=""){ command+=",";} command+="IsFrequent = "+POut.Bool(zipCode.IsFrequent)+""; } if(command==""){ return false; } command="UPDATE zipcode SET "+command +" WHERE ZipCodeNum = "+POut.Long(zipCode.ZipCodeNum); Db.NonQ(command); return true; }
public int SaveCustomerInfo(string fname, string lname, string add1, string add2, string city, string state, string zip, string hphone, string hext, string cphone, string cext, string email, string confemail, string comments) { bool csave = true; bool osave = true; DateTime dt = new DateTime(); dt = DateTime.Now; Customer newcustomer = new Customer(); Address newaddress = new Address(); Address newbilladdress = new Address(); ZipCode z = new ZipCode(); newbilladdress = null; z = DataHelper.FetchZipCode(zip, city, state); if (z != null) { SCAUserSession.SelectedZipCode = z.ZipCode; SCAUserSession.SelectedZipCodeID = z.ZipCodeID; FranchiseTerritory ft = new FranchiseTerritory(); ft = DataHelper.FetchFranchiseTerritoryByZipCodeIDProductRefID(z.ZipCodeID, SCUCConstants.ProductRefGarage); Owner ow = new Owner(); ow = DataHelper.GetOwnerByFranchise(new Guid(ft.FranchiseID.ToString())); SCAUserSession.SelectedOwnerID = ow.OwnerID; SCAUserSession.SelectedTerritoryID = new Guid(ft.TerritoryID.ToString()); Territory t = new Territory(); t = DataHelper.FetchTerritory(new Guid(SCAUserSession.SelectedTerritoryID.ToString())); SCAUserSession.SelectedOfficeID = new Guid(t.SchedulingOfficeID.ToString()); } csave = DataHelper.SaveCustomer_V2(SCAUserSession.SelectedBusinessRefID, SCAUserSession.SelectedOwnerID, SCAUserSession.SelectedOfficeID, SCAUserSession.SelectedTerritoryID, LoadCustomerInformation(fname, lname, email), LoadAddressInfo(add1, add2, city, state, zip), null, LoadPhoneInfo(hphone, hext, cphone, cext), string.Empty, ref newcustomer, ref newaddress, ref newbilladdress, SCAUserSession.SelectedUserName); if (csave) { SCAUserSession.SetNewCustomer(ref newcustomer, newaddress); SCAUserSession.SelectedCustomerID = newcustomer.CustomerID; SCAUserSession.SelectedCustomer = newcustomer; SeasCleanDataAccess.ServiceClasses.Order o = new SeasCleanDataAccess.ServiceClasses.Order(); Order euc = new Order(); SiteRef s = new SiteRef(); s = DataHelper.FetchSiteRef(new Guid(SCAUserSession.SelectedSiteID.ToString())); s.BusinessRefID = SCAUserSession.SelectedBusinessRefID; MarketingSource m = new MarketingSource(); m = DataHelper.SearchMarketingSource(s.Description, new Guid(SCAUserSession.SelectedTerritoryID.ToString()), false); List<MarketingSourceDetailFieldData> msdfds = new List<MarketingSourceDetailFieldData>(); foreach (MarketingSourceDetailFieldData msdf in msdfds) { string str = string.Empty; } SeasCleanDataAccess.ServiceClasses.ScheduleEntry oase = new SeasCleanDataAccess.ServiceClasses.ScheduleEntry(); oase.ScheduleDate = dt; SeasCleanDataAccess.ServiceClasses.TimeSlot ts = new SeasCleanDataAccess.ServiceClasses.TimeSlot(); ts.Type = "UNA"; oase.TimeSlots.Insert(0, ts); FranchiseTerritory ft = new FranchiseTerritory(); ft = DataHelper.FetchFranchiseTerritoryByTerritory(new Guid(SCAUserSession.SelectedTerritoryID.ToString())); ItemUnitTypeMaterialTypeSizeType iutmtst = new ItemUnitTypeMaterialTypeSizeType(); iutmtst = DataHelper.FetchItemUnitTypeMaterialTypeSizeType(new Guid(SCUCConstants.GarageDefaultIUTMTST.ToString())); SeasCleanDataAccess.ServiceClasses.OrderItem oi = new SeasCleanDataAccess.ServiceClasses.OrderItem(); oi.Type = SCUCConstants.GarageDefaultIUTMTST.ToString(); o.OrderItems.Add(oi); o.Notes = comments; osave = DataHelper.SaveOrder_V2(ref o, oase, ref newcustomer, ref newaddress, ref newbilladdress, ref euc, SCUCConstants.ProductRefGarage, m.MarketingSourceID, msdfds, ft, s, HttpContext.Current.Request.UserHostAddress, SCAUserSession.SelectedUserName, Guid.Empty); if (osave) { SCAUserSession.SelectedOrderID = euc.OrderID; SCAUserSession.SelectedOrderNumber = euc.OrderNumber; return int.Parse("3" + euc.OrderNumber.ToString()); } else { return 1; } } else { return 2; } }
///<summary>Updates one ZipCode in the database.</summary> public static void Update(ZipCode zipCode){ string command="UPDATE zipcode SET " +"ZipCodeDigits= '"+POut.String(zipCode.ZipCodeDigits)+"', " +"City = '"+POut.String(zipCode.City)+"', " +"State = '"+POut.String(zipCode.State)+"', " +"IsFrequent = "+POut.Bool (zipCode.IsFrequent)+" " +"WHERE ZipCodeNum = "+POut.Long(zipCode.ZipCodeNum); Db.NonQ(command); }
private void listMatches_DoubleClick(object sender, System.EventArgs e) { if(listMatches.SelectedIndex==-1){ return; } ZipSelected=(ZipCode)ZipCodes.ALMatches[listMatches.SelectedIndex]; DialogResult=DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if(listMatches.SelectedIndex==-1){ MessageBox.Show(Lan.g(this,"Please select an item first.")); return; } ZipSelected=(ZipCode)ZipCodes.ALMatches[listMatches.SelectedIndex]; DialogResult=DialogResult.OK; }
public void TestZipCode_Default() { var zip = new ZipCode(); Assert.IsNull(zip.Value); Assert.AreEqual("", zip.ToString()); }