public override int GetHashCode() { int code = 27; code = unchecked ( code ^ EmployeeID.GetHashCode() ^ FirstName.GetHashCode() ^ Title.GetHashCode() ^ TitleOfCourtesy.GetHashCode() ^ BirthDate.GetHashCode() ^ HireDate.GetHashCode() ^ Address.GetHashCode() ^ City.GetHashCode() ^ Region.GetHashCode() ^ PostalCode.GetHashCode() ^ Country.GetHashCode() ^ HomePhone.GetHashCode() ^ Extension.GetHashCode() ^ Photo.GetHashCode() ^ Notes.GetHashCode() ^ ReportsTo.GetHashCode() ^ PhotoPath.GetHashCode() ); return(code); }
public void FormattedShouldReturnEmptyWhenInvalid() { var phone = new HomePhone("31338724825"); var formattedNumber = phone.Formatted(); Assert.IsTrue(string.IsNullOrEmpty(formattedNumber)); }
public override int GetHashCode() { unchecked { var hashCode = Id; hashCode = (hashCode * 397) ^ (LastName != null ? LastName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FirstName != null ? FirstName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TitleOfCourtesy != null ? TitleOfCourtesy.GetHashCode() : 0); hashCode = (hashCode * 397) ^ BirthDate.GetHashCode(); hashCode = (hashCode * 397) ^ HireDate.GetHashCode(); hashCode = (hashCode * 397) ^ (Address != null ? Address.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Region != null ? Region.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PostalCode != null ? PostalCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Country != null ? Country.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HomePhone != null ? HomePhone.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Extension != null ? Extension.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Photo != null ? Photo.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Notes != null ? Notes.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ReportsTo.GetHashCode(); hashCode = (hashCode * 397) ^ (PhotoPath != null ? PhotoPath.GetHashCode() : 0); return(hashCode); } }
private void RemoveNonNumericFromHomePhone() { if (HomePhone != null) { HomePhone = HomePhone.RemoveNonNumeric().RemoveWhitespace(); } }
// returns string representation of patient object public override string ToString() { return(TitleName + "\t" + MaritalStatus + "" + " Age: " + Age + ", " + "Expenses: " + Salary.ToString("C") + ". " + HomeAddress + ". " + HomePhone.ToString() + "/" + CellPhone.ToString() + "\t"); } // end method ToString
public void AddHomePhone(HomePhone homePhone) { if (homePhone.Valid) { HomePhone = homePhone; } else { AddNotifications(homePhone); } }
// returns string representation of reservation object public override string ToString() { return(GuestType + " " + TitleName + "\t" + HomeAddress + "\t" + HomePhone.ToString() + ", " + MobilePhone.ToString() + ", " + Nights + " nights, " + RoomTypeName + "\t" + "Discount: " + DiscountRate.ToString() + "% " + "Room Charge: " + RoomCharge.ToString("C") + " " + "Tax: " + Tax.ToString("C") + " " + "Total: " + Total.ToString("C")); } // end method ToString
internal void AddPerson(int originid, int?entrypointid, int?campusid) { Family f; if (FamilyId > 0) { f = Family; } else { f = new Family(); AddressInfo.CopyPropertiesTo(f); f.ResCodeId = AddressInfo.ResCode.Value.ToInt2(); f.HomePhone = HomePhone.GetDigits(); } if (NickName != null) { NickName = NickName.Trim(); } var position = DbUtil.Db.ComputePositionInFamily(Age ?? -1, MaritalStatus.Value == "20", FamilyId) ?? 10; FirstName = FirstName.Trim(); if (FirstName == "na") { FirstName = ""; } person = Person.Add(f, position, null, FirstName.Trim(), NickName, LastName.Trim(), DOB, false, Gender.Value.ToInt(), originid, entrypointid); this.CopyPropertiesTo(Person); Person.CellPhone = CellPhone.GetDigits(); if (campusid == 0) { campusid = null; } Person.CampusId = Util.PickFirst(campusid.ToString(), DbUtil.Db.Setting("DefaultCampusId", "")).ToInt2(); if (Person.CampusId == 0) { Person.CampusId = null; } DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("AddPerson {0}".Fmt(person.PeopleId)); DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, Person); PeopleId = Person.PeopleId; }
public void TrimAllFields() { FirstName = FirstName.TrimIfNotNull(); LastName = LastName.TrimIfNotNull(); ZipCode = ZipCode.TrimIfNotNull(); MiddleName = MiddleName.TrimIfNotNull(); NameSuffix = NameSuffix.TrimIfNotNull(); Address = Address.TrimIfNotNull(); City = City.TrimIfNotNull(); State = State.TrimIfNotNull(); Email = Email.TrimIfNotNull(); CellPhone = CellPhone.TrimIfNotNull(); HomePhone = HomePhone.TrimIfNotNull(); Apartment = Apartment.TrimIfNotNull(); }
public void UpdatePerson() { var p = DbUtil.Db.LoadPersonById(PeopleId); if (Grade == null && p.Grade == 0) // special case to fix bug { p.Grade = null; } var changes = this.CopyPropertiesTo(p); p.LogChanges(DbUtil.Db, changes); var fsb = new List <ChangeDetail>(); p.Family.UpdateValue(fsb, "HomePhone", HomePhone.GetDigits()); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); if (p.DeceasedDateChanged) { var ret = p.MemberProfileAutomation(DbUtil.Db); if (ret != "ok") { Elmah.ErrorSignal.FromCurrentContext().Raise( new Exception(ret + " for PeopleId:" + p.PeopleId)); } } DbUtil.Db.SubmitChanges(); if (!HttpContext.Current.User.IsInRole("Access")) { changes.AddRange(fsb); if (changes.Count > 0) { var np = DbUtil.Db.GetNewPeopleManagers(); if (np != null) { DbUtil.Db.EmailRedacted(p.FromEmail, np, "Basic Person Info Changed on " + Util.Host, "{0} changed the following information for {1} ({2}):<br />\n" .Fmt(Util.UserName, FirstName + " " + LastName, PeopleId) + ChangeTable(changes)); } } } }
public override async Task Initialize() { FirstName = Prospect.FirstName; LastName = Prospect.LastName; MiddleName = Prospect.MiddleName; NickName = Prospect.NickName; StreetAddress = Prospect.StreetAddress == null ? new StreetAddress() : Prospect.StreetAddress.ShallowCopy(); FollowUpSettings = Prospect.FollowUpSettings.ShallowCopy(); MobilePhone = Prospect.MobilePhoneNumber == null ? new PhoneNumber() : Prospect.MobilePhoneNumber.ShallowCopy(); WorkPhone = Prospect.WorkPhoneNumber == null ? new PhoneNumber() : Prospect.WorkPhoneNumber.ShallowCopy(); HomePhone = Prospect.HomePhoneNumber == null ? new PhoneNumber() : Prospect.HomePhoneNumber.ShallowCopy(); Email = Prospect.Email == null ? new Email() : Prospect.Email.ShallowCopy(); _originalProspect = Prospect.ShallowCopy(); _originalProspect.FollowUpSettings = FollowUpSettings.ShallowCopy(); _originalProspect.StreetAddress = StreetAddress.ShallowCopy(); _originalProspect.MobilePhoneNumber = MobilePhone.ShallowCopy(); _originalProspect.WorkPhoneNumber = WorkPhone.ShallowCopy(); _originalProspect.HomePhoneNumber = HomePhone.ShallowCopy(); _originalProspect.Email = Email.ShallowCopy(); Prefixes = (await _userDefinedCodeService.GetPrefixUserDefinedCodes()).ToObservableCollection(); ActivePrefix = Prefixes.FirstOrDefault(p => p.Description1 == Prospect.NamePrefix); Suffixes = (await _userDefinedCodeService.GetSuffixUserDefinedCodes()).ToObservableCollection(); ActiveSuffix = Suffixes.FirstOrDefault(p => p.Description1 == Prospect.NameSuffix); ContactPreferences = (await _userDefinedCodeService.GetContactPreferenceUserDefinedCodes()).ToObservableCollection(); ActiveContactPreference = ContactPreferences.FirstOrDefault(p => p.Description1 == Prospect.FollowUpSettings.PreferredContactMethod); ExcludeReasons = (await _userDefinedCodeService.GetExcludeReasonUserDefinedCodes()).ToObservableCollection(); ActiveExcludeReason = ExcludeReasons.FirstOrDefault(p => p.Code == Prospect.FollowUpSettings.ExcludeReason); States = (await _userDefinedCodeService.GetStateUserDefinedCodes()).ToObservableCollection(); ActiveState = Prospect.StreetAddress != null?States.FirstOrDefault(p => p.Code == Prospect.StreetAddress.State) : null; Countries = (await _userDefinedCodeService.GetCountryUserDefinedCodes()).ToObservableCollection(); ActiveCountry = Prospect.StreetAddress != null?Countries.FirstOrDefault(p => p.Code == Prospect.StreetAddress.Country) : null; TrafficSources = (await _trafficSourceService.GetTrafficSourcesByDivision(Prospect.ProspectCommunity.Division)).ToObservableCollection(); ActiveTrafficSource = TrafficSources.FirstOrDefault(t => t.TrafficSourceDetails.Any(td => td.CodeId == Prospect.TrafficSourceCodeId)); if (ActiveTrafficSource != null) { ActiveTrafficSourceDetail = ActiveTrafficSource.TrafficSourceDetails.First(td => td.CodeId == Prospect.TrafficSourceCodeId); } }
public void UpdatePerson(CMSDataContext db) { var p = db.LoadPersonById(PeopleId); if (Grade == null && p.Grade == 0) // special case to fix bug { p.Grade = null; } var changes = this.CopyPropertiesTo(p); p.LogChanges(db, changes); var fsb = new List <ChangeDetail>(); p.Family.UpdateValue(fsb, "HomePhone", HomePhone.GetDigits()); p.Family.LogChanges(db, fsb, p.PeopleId, db.UserPeopleId ?? 0); if (p.DeceasedDateChanged) { var ret = p.MemberProfileAutomation(db); if (ret != "ok") { Elmah.ErrorSignal.FromCurrentContext().Raise( new Exception(ret + " for PeopleId:" + p.PeopleId)); } } db.SubmitChanges(); if (!HttpContextFactory.Current.User.IsInRole("Access")) { changes.AddRange(fsb); if (changes.Count > 0) { var np = db.GetNewPeopleManagers(); if (np != null) { db.EmailRedacted(p.FromEmail, np, "Basic Person Info Changed on " + db.Host, $"{Util.UserName} changed the following information for <a href='{db.ServerLink($"/Person2/{PeopleId}")}'>{FirstName} {LastName}</a> ({PeopleId}):<br />\n" + ChangeTable(changes)); } } } }
/// <summary> /// Validates the specified validation context. /// </summary> /// <param name="validationContext">The validation context.</param> /// <returns></returns> public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { //Last Name if (string.IsNullOrWhiteSpace(LastName)) { yield return(new ValidationResult( string.Format(AppConstants.ErrorMessages.ShouldNotBeEmpty, Property(r => r.LastName)), new[] { Property(r => r.LastName).ToString(), "IsNullOrWhiteSpace" })); } //Email if (!Email.IsValidEmailAddress()) { yield return(new ValidationResult( string.Format(AppConstants.ErrorMessages.MustBeValidEmail, Property(r => r.Email)), new[] { Property(r => r.Email).ToString(), "IsValidEmailAddress" })); } //Phone Number if (!HomePhone.IsValidPhoneNumber()) { yield return(new ValidationResult( string.Format(AppConstants.ErrorMessages.MustBeValidPhoneNumber, Property(r => r.HomePhone)), new[] { Property(r => r.HomePhone).ToString(), "IsValidPhoneNumber" })); } //Phone Number if (!MobilePhone.IsValidPhoneNumber()) { yield return(new ValidationResult( string.Format(AppConstants.ErrorMessages.MustBeValidPhoneNumber, Property(r => r.MobilePhone)), new[] { Property(r => r.MobilePhone).ToString(), "IsValidPhoneNumber" })); } //Phone Number if (!WorkPhone.IsValidPhoneNumber()) { yield return(new ValidationResult( string.Format(AppConstants.ErrorMessages.MustBeValidPhoneNumber, Property(r => r.WorkPhone)), new[] { Property(r => r.WorkPhone).ToString(), "IsValidPhoneNumber" })); } }
public override void FillEntities() { var name = new Name(FirstName, LastName); var email = new Email(Address); Prospect = new Entities.Prospect(name, email); if (!string.IsNullOrEmpty(CellPhone)) { var cellPhone = new CellPhone(CellPhone, IsWhatsApp); Prospect.AddCellPhone(cellPhone); } if (!string.IsNullOrEmpty(HomePhone)) { var homePhone = new HomePhone(HomePhone); Prospect.AddHomePhone(homePhone); } AddNotifications(name, email, Prospect); }
public override async Task Initialize() { _user = await _userService.GetLoggedInUser(); _originalCobuyer = Cobuyer.ShallowCopy(); _originalCobuyer.StreetAddress = StreetAddress.ShallowCopy(); _originalCobuyer.MobilePhoneNumber = MobilePhone.ShallowCopy(); _originalCobuyer.WorkPhoneNumber = WorkPhone.ShallowCopy(); _originalCobuyer.HomePhoneNumber = HomePhone.ShallowCopy(); _originalCobuyer.Email = Email.ShallowCopy(); Prefixes = (await _userDefinedCodeService.GetPrefixUserDefinedCodes()).ToObservableCollection(); ActivePrefix = Prefixes.FirstOrDefault(p => p.Description1 == Cobuyer.NamePrefix); Suffixes = (await _userDefinedCodeService.GetSuffixUserDefinedCodes()).ToObservableCollection(); ActiveSuffix = Suffixes.FirstOrDefault(p => p.Description1 == Cobuyer.NameSuffix); States = (await _userDefinedCodeService.GetStateUserDefinedCodes()).ToObservableCollection(); ActiveState = Cobuyer.StreetAddress != null?States.FirstOrDefault(p => p.Code == Cobuyer.StreetAddress.State) : null; Countries = (await _userDefinedCodeService.GetCountryUserDefinedCodes()).ToObservableCollection(); ActiveCountry = Cobuyer.StreetAddress != null?Countries.FirstOrDefault(p => p.Code == Cobuyer.StreetAddress.Country) : null; }
public override int GetHashCode() { unchecked { var hashCode = Id.GetHashCode(); hashCode = (hashCode * 397) ^ EntityRefId.GetHashCode(); hashCode = (hashCode * 397) ^ (Employer != null ? Employer.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ContactTypeId; hashCode = (hashCode * 397) ^ PreferredContactMethodType; hashCode = (hashCode * 397) ^ IsPrimary.GetHashCode(); hashCode = (hashCode * 397) ^ (FirstName != null ? FirstName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MiddleName != null ? MiddleName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (LastName != null ? LastName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (JobTitle != null ? JobTitle.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BusinessPhone != null ? BusinessPhone.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MobilePhone != null ? MobilePhone.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HomePhone != null ? HomePhone.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Email != null ? Email.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CreatedOn.GetHashCode(); hashCode = (hashCode * 397) ^ ModifiedOn.GetHashCode(); return(hashCode); } }
public void FillForm(User user) { FirstName.SendKeys(user.FirstName); LastName.SendKeys(user.LastName); Password.SendKeys(user.Password); Days.Click(); DayOption.Click(); Months.Click(); MonthOption.Click(); Years.Click(); YearOption.Click(); Address.SendKeys(user.Address); City.SendKeys(user.City); State.Click(); StateOption.Click(); Zip.SendKeys(user.ZipCode); HomePhone.SendKeys(user.HomePhone); Mobile.SendKeys(user.MobilePhone); AddressAlias.Clear(); AddressAlias.SendKeys(user.AddressAlias); RegisterButton.Click(); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (FirstName == null) { FirstName = string.Empty; } else { FirstName = FirstName.Trim(); FirstName = ASValidations.ASCapitalize(FirstName).ToString(); } if (LastName == null) { LastName = string.Empty; } else { LastName = LastName.Trim(); LastName = ASValidations.ASCapitalize(LastName).ToString(); } if (Gender == null) { Gender = string.Empty; } else { Gender = Gender.Trim(); Gender = ASValidations.ASCapitalize(Gender).ToString(); } if (Address == null) { Address = string.Empty; } else { Address = Address.Trim(); Address = ASValidations.ASCapitalize(Address).ToString(); } if (City == null) { City = string.Empty; } else { City = City.Trim(); City = ASValidations.ASCapitalize(City).ToString(); } if (ProvinceCode != null) { var provSearch = _context.Province.Where(p => p.ProvinceCode == ProvinceCode).FirstOrDefault(); if (provSearch == null) { yield return(new ValidationResult("Province code is not on file", new[] { nameof(ProvinceCode) })); yield return(new ValidationResult("Province code is required to validate Postal Code", new[] { nameof(PostalCode) })); } else { var countrySearch = _context.Country.Where(a => a.CountryCode == provSearch.CountryCode).FirstOrDefault(); if (provSearch.CountryCode == "CA") { ProvinceCode = ProvinceCode.Trim(); ProvinceCode = ProvinceCode.ToUpper(); if (PostalCode != null || PostalCode == "") { PostalCode = PostalCode.Trim().ToUpper(); if (provSearch.FirstPostalLetter.Contains(PostalCode.Substring(0, 1)) == false) { yield return(new ValidationResult("First letter of postal code not valid for given province", new[] { nameof(PostalCode) })); } else { if (ASValidations.ASPostalCodeValidation(PostalCode) == false) { yield return(new ValidationResult("Postal code not in cdn format: A3A 3A3", new[] { nameof(PostalCode) })); } else { PostalCode = string.Format("{0} {1}", PostalCode.Substring(0, 3), PostalCode.Substring(3)); } } } } else if (provSearch.CountryCode == "US") { ProvinceCode = ProvinceCode.Trim(); if (!String.IsNullOrEmpty(PostalCode)) { PostalCode = PostalCode.Trim(); if (!ASValidations.ASZipCodeValidation(PostalCode)) { yield return(new ValidationResult("US Zip code format incorrect: 12345 / 12345-6789", new[] { nameof(PostalCode) })); } } } } } if ((Deceased == true) && (DateOfDeath == null)) { yield return(new ValidationResult("If deceased is true, a date of death is required", new[] { nameof(DateOfDeath) })); } else if ((Deceased == false) && (DateOfDeath != null)) { yield return(new ValidationResult("Deceased must be true, if Date of Death is provided", new[] { nameof(Deceased) })); } if (Ohip != null) { Ohip = Ohip.ToUpper(); } if (HomePhone != null) { HomePhone = HomePhone.Trim(); var HomePhoneNumber = ASValidations.ASExtractDigits(HomePhone).ToString(); if (HomePhoneNumber.Length != 10) { yield return(new ValidationResult("Home Phone if provided, should be 10 digits: 123-123-1234", new[] { nameof(HomePhone) })); } else { HomePhone = string.Format("{0}-{1}-{2}", HomePhoneNumber.Substring(0, 3), HomePhoneNumber.Substring(3, 3), HomePhoneNumber.Substring(6)); } } yield return(ValidationResult.Success); }
public string GetAllProperties() { string fullName = (Name.Trim() == "" ? ("") : Name.Trim()) + (MiddleName.Trim() == "" ? ("") : " " + MiddleName.Trim()) + (Surname.Trim() == "" ? ("") : " " + Surname.Trim()); string generalInfo = (fullName == "" ? ("") : fullName + "\r\n") + (Nickname == "" ? ("") : Nickname.Trim() + "\r\n") + (Title == "" ? ("") : Title.Trim() + "\r\n") + (Company == "" ? ("") : Company.Trim() + "\r\n") + (Address.Trim() == "" ? ("") : Address.Trim() + "\r\n"); string phones = (HomePhone == "" ? ("") : "H: " + HomePhone.Trim() + "\r\n") + (MobilePhone == "" ? ("") : "M: " + MobilePhone.Trim() + "\r\n") + (WorkPhone == "" ? ("") : "W: " + WorkPhone.Trim() + "\r\n") + (Fax == "" ? ("") : "F:" + Fax.Trim() + "\r\n"); string emails = (Email1 == "" ? ("") : "" + Email1.Trim() + "\r\n") + (Email2 == "" ? ("") : "" + Email2.Trim() + "\r\n") + (Email3 == "" ? ("") : "" + Email3.Trim() + "\r\n") + (Homepage == "" ? ("") : "Homepage:" + "\r\n" + Homepage.Trim() + "\r\n"); string dateOfBirth = ""; if (DayOfBirth != "-" && DayOfBirth != "0" || MonthOfBirth != "-" || YearOfBirth != "") { dateOfBirth = "Birthday " + (DayOfBirth == "-" || DayOfBirth == "0" ? ("") : DayOfBirth + ". ") + (MonthOfBirth == "-" ? ("") : MonthOfBirth + " ") + (YearOfBirth == "" ? ("") : YearOfBirth + " (" + (DateTime.Now.Year - Convert.ToInt32(YearOfBirth)).ToString() + ")" + "\r\n"); } string dateOfAnn = ""; if (DayOfAnn != "-" && DayOfAnn != "0" || MonthOfAnn != "-" || YearOfAnn != "") { dateOfAnn = "Anniversary " + (DayOfAnn == "-" ? ("") : DayOfAnn + ". ") + (MonthOfAnn == "-" ? ("") : MonthOfAnn + " ") + (YearOfAnn == "" ? ("") : YearOfAnn + " (" + (DateTime.Now.Year - Convert.ToInt32(YearOfAnn)).ToString() + ")\r\n"); } string dates = (dateOfBirth == "" ? ("") : dateOfBirth) + (dateOfAnn == "" ? ("") : dateOfAnn); string additional = (Address2 == "" ? ("") : Address2.Trim() + "\r\n") + (Phone2 == "" ? ("") : "\r\nP: " + Phone2.Trim() + "\r\n") + (Notes == "" ? ("") : "\r\n" + Notes.Trim()); string allProperties = ((generalInfo == "" ? ("") : generalInfo) + (phones == "" ? ("") : "\r\n" + phones) + (emails == "" ? ("") : "\r\n" + emails) + (dates == "" ? ("") : "\r\n" + dates) + (additional == "" ? ("") : "\r\n" + additional)).Trim(); return(allProperties); }
public EA_POM Create_Appoinment() { Web_Driver.ngWebDriver.WaitForAngular(); Web_Driver.driver.Navigate().Refresh(); Apponitment_Tab.ElementAt(0).Click(); //Clicking on Create Appoinment Button Web_Driver.ngWebDriver.WaitForAngular(); Pre_Id = Previous_ID_txt.ElementAt(0).Text; int.TryParse(Pre_Id, out Previous_ID); Web_Driver.ngWebDriver.WaitForAngular(); Created_Appoinment_Button.Click(); //getting Appoinment page Url Appoinment_Page_Url = Web_Driver.driver.Url; //Clicking on CheckBox Check_Boxe.Click(); //Checking Fields are Enabled after cliking on Checkbox for (int i = 0; i < Enable_Input_Boxes.Count; i++) { if (Enable_Input_Boxes.ElementAt(i).Enabled) { Asserts.Enable_Fields(true); } if (Enable_Input_Boxes.ElementAt(i).Enabled == false) { Asserts.Enable_Fields(false); } } //passing data into Fields // pass data into representative Form Representative_First_Name.SendKeys("Usama"); Representative_First_Name.GetAttribute("value"); Representative_Last_Name.SendKeys("Sohail"); Representative_Last_Name.GetAttribute("value"); Representative_Relationship.SendKeys("Cousin"); Representative_Relationship.GetAttribute("value"); RepresentativePhoneNumber.SendKeys("(234) 678-9874"); string repres_str = RepresentativePhoneNumber.GetAttribute("value"); //Passing Agent Info AgentFirstName.Clear(); AgentFirstName.SendKeys("Ahad"); AgentFirstName.GetAttribute("value"); AgentLastName.Clear(); AgentLastName.SendKeys("Ahmed"); AgentLastName.GetAttribute("value"); AgentPhone.Clear(); AgentPhone.SendKeys("2346789874"); string str_AgentPhone = AgentPhone.GetAttribute("value"); str_AgentPhone = str_AgentPhone.Substring(str_AgentPhone.IndexOf("(")); str_AgentPhone = str_AgentPhone.Replace("(", ""); str_AgentPhone = str_AgentPhone.Replace(")", ""); str_AgentPhone = str_AgentPhone.Replace("-", ""); // Console.WriteLine(str_AgentPhone); //passing data into Benificiary Beneficiary_First_Name.SendKeys("Mujeed"); Beneficiary_First_Name.GetAttribute("value"); LastName.SendKeys("Khan"); LastName.GetAttribute("value"); EmailAddress.SendKeys("*****@*****.**"); HomePhone.SendKeys("2346789874"); HomePhone.GetAttribute("value"); PermanentAddress.SendKeys("72 house 342"); //Checking radio buttons for (int i = 0; i < Radio_Btn_list.Count; i++) { Radio_Btn_list.ElementAt(i).Click(); Console.WriteLine(Radio_Btn_list.ElementAt(i).Selected); } //Passing Data into other InitialOtherContactMethod.SendKeys("Other"); InitialOtherContactMethod.SendKeys("value"); //passing data into plan PlansRepresented.SendKeys("Plan A"); PlansRepresented.GetAttribute("value"); //passing dates AppointmentOn.SendKeys("12/10/2020"); AppointmentOn.GetAttribute("value"); AppointmentCompletedOn.SendKeys("13/10/2020"); AppointmentCompletedOn.GetAttribute("value"); //passing data into Appointment Id AgnetNPNIDNumber.SendKeys("Md-4554"); AgnetNPNIDNumber.GetAttribute("value"); //passing data into plan meetingDetails.SendKeys("Plan D"); meetingDetails.GetAttribute("value"); // Medicare Number MediCareNumber.SendKeys("Md-6783"); MediCareNumber.GetAttribute("value"); // Asserts.All_Fields_Data_Filled if (Representative_First_Name.contains("[a-zA-Z0-9]+") && RepresentativePhoneNumber.contains("[0-9]+") == true); // Asserts.All_Fields_Data_Filled(false); //Assertion On Data filled or Not if (Representative_First_Name.GetAttribute("value") == "Usama" && Representative_Last_Name.GetAttribute("value") == "Sohail" && Representative_Relationship.GetAttribute("value") == "Cousin" && AgentFirstName.GetAttribute("value") == "Ahad" && AgentLastName.GetAttribute("value") == "Ahmed" && str_AgentPhone == "234 6789874" && Beneficiary_First_Name.GetAttribute("value") == "Mujeed" && LastName.GetAttribute("value") == "Khan" && repres_str == "(234) 678-9874" && PermanentAddress.GetAttribute("value") == "72 house 342" && EmailAddress.GetAttribute("value") == "*****@*****.**" && PlansRepresented.GetAttribute("value") == "Plan A" && AppointmentOn.GetAttribute("value") == "10/12/2020" && AppointmentCompletedOn.GetAttribute("value") == "10/13/2020" && AgnetNPNIDNumber.GetAttribute("value") == "Md-4554" && MediCareNumber.GetAttribute("value") == "Md-6783") { Asserts.All_Fields_Data_Filled(true); } else { Asserts.All_Fields_Data_Filled(false); } //Assertion on Date Date_of_Appoinment = AppointmentOn.GetAttribute("value"); Date_of_Appoinment = Date_of_Appoinment.Substring(Date_of_Appoinment.IndexOf("/")); Date_of_Appoinment = Date_of_Appoinment.Replace("/", ""); // Complete Date Date_of_Appoinment_Complete = AppointmentCompletedOn.GetAttribute("value"); Date_of_Appoinment_Complete = Date_of_Appoinment_Complete.Substring(Date_of_Appoinment_Complete.IndexOf("/")); Date_of_Appoinment_Complete = Date_of_Appoinment_Complete.Replace("/", ""); int.TryParse(Date_of_Appoinment_Complete, out int Complete_Date); int.TryParse(Date_of_Appoinment, out int Start_Date); Console.WriteLine(Complete_Date); Console.WriteLine(Start_Date); if (Complete_Date > Start_Date) { Asserts.Date(true); } else { Asserts.Date(false); } //Clicking on E Sign button Genrete_Appoinment.ElementAt(0).Click(); Genrete_Appoinment_Yes_Btn.ElementAt(1).Click(); Web_Driver.ngWebDriver.WaitForAngular(); Genrete_Appoinment_Ok_Btn.ElementAt(1).Click(); Web_Driver.ngWebDriver.WaitForAngular(); Web_Driver.driver.Navigate().Refresh(); Home_Page_Url = Web_Driver.driver.Url; Console.WriteLine(Home_Page_Url); Console.WriteLine(Appoinment_Page_Url); Web_Driver.ngWebDriver.WaitForAngular(); Up_Id = Created_ID_txt.ElementAt(0).Text; int.TryParse(Up_Id, out Updated_ID); Asserts.ID_Compare(Updated_ID, Previous_ID); Console.WriteLine(Previous_ID); Console.WriteLine(Updated_ID); return(new EA_POM()); }
public void UpdatePerson() { if (CampusId == 0) { CampusId = null; } var p = DbUtil.Db.LoadPersonById(PeopleId); var psb = new StringBuilder(); var fsb = new StringBuilder(); p.UpdateValue(psb, "DOB", Birthday); p.UpdateValue(psb, "CampusId", CampusId); p.UpdateValue(psb, "DeceasedDate", DeceasedDate); p.UpdateValue(psb, "DoNotCallFlag", DoNotCallFlag); p.UpdateValue(psb, "DoNotMailFlag", DoNotMailFlag); p.UpdateValue(psb, "DoNotVisitFlag", DoNotVisitFlag); p.UpdateValue(psb, "DoNotPublishPhones", DoNotPublishPhones); p.UpdateValue(psb, "EmailAddress", PrimaryEmail.Address); p.UpdateValue(psb, "EmailAddress2", AltEmail.Address); p.UpdateValue(psb, "SendEmailAddress1", PrimaryEmail.Send); p.UpdateValue(psb, "SendEmailAddress2", AltEmail.Send); p.UpdateValue(psb, "FirstName", FirstName); p.UpdateValue(psb, "LastName", LastName); p.UpdateValue(psb, "AltName", AltName); p.UpdateValue(psb, "GenderId", Gender.Value.ToInt2()); p.UpdateValue(psb, "Grade", Grade.ToInt2()); p.UpdateValue(psb, "CellPhone", Mobile.GetDigits()); p.Family.UpdateValue(fsb, "HomePhone", HomePhone.GetDigits()); p.UpdateValue(psb, "MaidenName", FormerName); p.UpdateValue(psb, "MaritalStatusId", Marital.Value.ToInt2()); p.UpdateValue(psb, "MiddleName", MiddleName); p.UpdateValue(psb, "NickName", GoesBy); p.UpdateValue(psb, "OccupationOther", Occupation); p.UpdateValue(psb, "SchoolOther", School); p.UpdateValue(psb, "SuffixCode", Suffix); p.UpdateValue(psb, "EmployerOther", Employer); p.UpdateValue(psb, "TitleCode", Title.Value); p.UpdateValue(psb, "WeddingDate", WeddingDate.ToDate()); p.UpdateValue(psb, "WorkPhone", Work.GetDigits()); if (p.DeceasedDateChanged) { var ret = p.MemberProfileAutomation(DbUtil.Db); if (ret != "ok") { Elmah.ErrorSignal.FromCurrentContext().Raise( new Exception(ret + " for PeopleId:" + p.PeopleId)); } } p.LogChanges(DbUtil.Db, psb, Util.UserPeopleId.Value); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId.Value); DbUtil.Db.SubmitChanges(); if (!HttpContext.Current.User.IsInRole("Access")) { if (psb.Length > 0 || fsb.Length > 0) { DbUtil.Db.EmailRedacted(p.FromEmail, DbUtil.Db.GetNewPeopleManagers(), "Basic Person Info Changed on " + Util.Host, "{0} changed the following information for {1} ({2}):<br />\n<table>{3}{4}</table>" .Fmt(Util.UserName, FirstName + " " + LastName, PeopleId, psb.ToString(), fsb.ToString())); } } }
public Paragraph AddPhones(bool keepnext) { var paragraph1 = new Paragraph { RsidParagraphMarkRevision = "00E7001C", RsidParagraphAddition = "00E7001C", RsidParagraphProperties = "005205ED", RsidRunAdditionDefault = "00E7001C" }; var paragraphProperties1 = new ParagraphProperties(); var spacingBetweenLines1 = new SpacingBetweenLines { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto }; var paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); var runFonts1 = new RunFonts { ComplexScriptTheme = ThemeFontValues.MinorHighAnsi }; var fontSize1 = new FontSize { Val = "20" }; var fontSizeComplexScript1 = new FontSizeComplexScript { Val = "20" }; paragraphMarkRunProperties1.Append(runFonts1); paragraphMarkRunProperties1.Append(fontSize1); paragraphMarkRunProperties1.Append(fontSizeComplexScript1); var keeplines = new KeepLines(); paragraphProperties1.Append(keeplines); if (keepnext) { paragraphProperties1.Append(new KeepNext()); } paragraphProperties1.Append(spacingBetweenLines1); paragraphProperties1.Append(paragraphMarkRunProperties1); paragraph1.Append(paragraphProperties1); var needbreak = false; if (HomePhone.HasValue()) { var run1 = new Run { RsidRunProperties = "00E7001C" }; if (needbreak) { run1.Append(new Break()); } needbreak = true; var runProperties1 = new RunProperties(); var runFonts2 = new RunFonts { ComplexScriptTheme = ThemeFontValues.MinorHighAnsi }; var fontSize3 = new FontSize { Val = "20" }; runProperties1.Append(fontSize3); runProperties1.Append(runFonts2); var text1 = new Text(); text1.Text = HomePhone.FmtFone("H"); run1.Append(runProperties1); run1.Append(text1); paragraph1.Append(run1); } if (head.Cell.HasValue()) { var run4 = new Run { RsidRunProperties = "00E7001C" }; if (needbreak) { run4.Append(new Break()); } needbreak = true; var runProperties4 = new RunProperties(); var runFonts5 = new RunFonts { ComplexScriptTheme = ThemeFontValues.MinorHighAnsi }; var fontSize3 = new FontSize { Val = "20" }; runProperties4.Append(fontSize3); runProperties4.Append(runFonts5); var text3 = new Text(); text3.Text = $"C {head.First}: {head.Cell.FmtFone()}"; run4.Append(runProperties4); run4.Append(text3); paragraph1.Append(run4); } if (spouse != null && spouse.Cell.HasValue()) { var run4 = new Run { RsidRunProperties = "00E7001C" }; if (needbreak) { run4.Append(new Break()); } needbreak = true; var runProperties4 = new RunProperties(); var runFonts5 = new RunFonts { ComplexScriptTheme = ThemeFontValues.MinorHighAnsi }; var fontSize3 = new FontSize { Val = "20" }; runProperties4.Append(fontSize3); runProperties4.Append(runFonts5); var text3 = new Text(); text3.Text = $"C {spouse.First}: {spouse.Cell.FmtFone()}"; run4.Append(runProperties4); run4.Append(text3); paragraph1.Append(run4); } return(paragraph1); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (FirstName.Trim().Length == 0) { yield return(new ValidationResult("FirstName cannot be empty or blank ", new[] { "FirstName" })); } if (LastName.Trim().Length == 0) { yield return(new ValidationResult("FirstName cannot be empty or blank ", new[] { "LastName" })); } if (UseCanadaPost == true) { if (string.IsNullOrEmpty(Street)) { yield return(new ValidationResult("Street is Required ", new[] { "Street" })); } if (string.IsNullOrEmpty(City)) { yield return(new ValidationResult("City is Required ", new[] { "City" })); } Street = Street.Trim(); City = City.Trim(); } if (UseCanadaPost == false) { if (string.IsNullOrEmpty(Email)) { yield return(new ValidationResult("Email is Required ", new[] { "Email" })); } else { Email = Email.Trim(); } } // MemberId = _context.Member.Max(a => a.MemberId) + 1; //var memberid = _context.Member.Where(a => a.MemberId == MemberId).FirstOrDefault(); //if (memberid != null) //{ // yield return new ValidationResult("Member is already on file", new[] { "MemberId" }); //} ProvinceCode = ProvinceCode.Trim(); ProvinceCode = ProvinceCode.ToUpper(); if (ProvinceCode.Length != 2) { yield return(new ValidationResult("ProvinceCode length is not match ", new[] { "ProvinceCode" })); } var province = _context.Member.Where(a => a.ProvinceCode == ProvinceCode).FirstOrDefault(); if (province == null) { yield return(new ValidationResult("ProvinceCode is not match ", new[] { "ProvinceCode" })); } if (!string.IsNullOrEmpty(PostalCode)) { PostalCode = PostalCode.ToUpper().Trim(); Regex PostalValidation = new Regex(@"^(?!.*[DFIOQU])[A-VXY][0-9][A-Z][0-9][A-Z][0-9]$"); if (!PostalValidation.IsMatch(PostalCode)) { yield return(new ValidationResult("PostalCode is not match ", new[] { "PostalCode" })); } else { PostalCode = PostalCode.Insert(3, " "); } } if (!string.IsNullOrEmpty(HomePhone)) { HomePhone = HomePhone.Trim(); Regex PhoneValidation = new Regex(@"^\(?[0-9]{3}(\-|\)) ?[0-9]{3}-[0-9]{4}$"); if (HomePhone.Length != 10 && !PhoneValidation.IsMatch(HomePhone)) { yield return(new ValidationResult("Home Phone should only be 10 digits", new[] { "HomePhone" })); } else { HomePhone = HomePhone.Insert(3, "-"); HomePhone = HomePhone.Insert(7, "-"); } } if (!string.IsNullOrEmpty(SpouseFirstName)) { if (!string.IsNullOrEmpty(SpouseLastName)) { SpouseFirstName = SpouseFirstName.Trim(); SpouseLastName = SpouseLastName.Trim(); FullName = LastName + ", " + FirstName + "&" + SpouseLastName + ", " + SpouseFirstName; } else { FullName = LastName + ", " + FirstName + "&" + SpouseFirstName; } } else { FirstName = FirstName.Trim(); LastName = LastName.Trim(); FullName = LastName + ", " + FirstName; } }
public override int GetHashCode() { int hash = 1; if (GivenName.Length != 0) { hash ^= GivenName.GetHashCode(); } if (GivenName2.Length != 0) { hash ^= GivenName2.GetHashCode(); } if (FamilyName.Length != 0) { hash ^= FamilyName.GetHashCode(); } if (Email.Length != 0) { hash ^= Email.GetHashCode(); } if (HomePhone.Length != 0) { hash ^= HomePhone.GetHashCode(); } if (MobilePhone.Length != 0) { hash ^= MobilePhone.GetHashCode(); } if (FaxNumber.Length != 0) { hash ^= FaxNumber.GetHashCode(); } if (OfficePhone.Length != 0) { hash ^= OfficePhone.GetHashCode(); } if (OfficeAddress1.Length != 0) { hash ^= OfficeAddress1.GetHashCode(); } if (OfficeAddress2.Length != 0) { hash ^= OfficeAddress2.GetHashCode(); } if (OfficeCity.Length != 0) { hash ^= OfficeCity.GetHashCode(); } if (OfficeState.Length != 0) { hash ^= OfficeState.GetHashCode(); } if (OfficeZip.Length != 0) { hash ^= OfficeZip.GetHashCode(); } if (OfficeNation.Length != 0) { hash ^= OfficeNation.GetHashCode(); } if (HomeAddress1.Length != 0) { hash ^= HomeAddress1.GetHashCode(); } if (HomeAddress2.Length != 0) { hash ^= HomeAddress2.GetHashCode(); } if (HomeCity.Length != 0) { hash ^= HomeCity.GetHashCode(); } if (HomeState.Length != 0) { hash ^= HomeState.GetHashCode(); } if (HomeZip.Length != 0) { hash ^= HomeZip.GetHashCode(); } if (HomeNation.Length != 0) { hash ^= HomeNation.GetHashCode(); } if (CompanyName.Length != 0) { hash ^= CompanyName.GetHashCode(); } return(hash); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { OECContext _context = OEC_Singleton.Context(); FarmId = Convert.ToInt32(FarmId.ToString().Trim()); if (Name != null) { Name = Name.Trim(); Name = HKValidations.HKCapitalize(Name); } if (Address != null) { Address = Address.Trim(); Address = HKValidations.HKCapitalize(Address); } if (Town != null) { Town = Town.Trim(); Town = HKValidations.HKCapitalize(Town); } if (County != null) { County = County.Trim(); County = HKValidations.HKCapitalize(County); } if (ProvinceCode != null) { ProvinceCode = ProvinceCode.Trim(); ProvinceCode = ProvinceCode.ToUpper(); } if (PostalCode != null) { PostalCode = PostalCode.Trim(); } if (HomePhone != null) { HomePhone = HomePhone.Trim(); } if (CellPhone != null) { CellPhone = CellPhone.Trim(); } if (Email != null) { Email = Email.Trim(); } if (Directions != null) { Directions = Directions.Trim(); } if (String.IsNullOrWhiteSpace(Name) || String.IsNullOrWhiteSpace(ProvinceCode)) { if (String.IsNullOrWhiteSpace(Name)) { yield return(new ValidationResult("Name is required", new[] { "Name" })); } if (String.IsNullOrWhiteSpace(ProvinceCode)) { yield return(new ValidationResult("Province Code is required", new[] { "ProvinceCode" })); } } if (String.IsNullOrWhiteSpace(Town) && String.IsNullOrWhiteSpace(County)) { yield return(new ValidationResult("Either the town or county must be provided.", new[] { "Town", "County" })); } if (String.IsNullOrWhiteSpace(Email)) { if (string.IsNullOrWhiteSpace(Address)) { yield return(new ValidationResult("Address must be provided.", new[] { "Address" })); } if (string.IsNullOrWhiteSpace(PostalCode)) { yield return(new ValidationResult("Postal Code must be provided.", new[] { "PostalCode" })); } } if (!String.IsNullOrEmpty(PostalCode) && !String.IsNullOrWhiteSpace(ProvinceCode)) { string countryCode = ""; if (ProvinceCode.Length == 2) { countryCode = _context.Province.SingleOrDefault(p => p.ProvinceCode == ProvinceCode).CountryCode; } else { countryCode = _context.Province.SingleOrDefault(p => p.Name == ProvinceCode).CountryCode; } if (countryCode == "CA") { string pCode = PostalCode; if (!HKValidations.HKPostalCodeValidation(ref pCode)) { yield return(new ValidationResult("Please enter valid postal code.", new[] { "PostalCode" })); } PostalCode = pCode; } else if (countryCode == "US") { string zCode = PostalCode; if (!HKValidations.HKZipCodeValidation(ref zCode)) { yield return(new ValidationResult("Please enter valid zip code.", new[] { "PostalCode" })); } PostalCode = zCode; } } if (String.IsNullOrWhiteSpace(HomePhone) && String.IsNullOrWhiteSpace(CellPhone)) { yield return(new ValidationResult("Either the home phone number or cell phone number must be provided.", new[] { "HomePhone", "CellPhone" })); } else { if (!String.IsNullOrWhiteSpace(HomePhone)) { string hPhone = HomePhone; if (!HKValidations.HKPhoneNumberValidation(ref hPhone)) { yield return(new ValidationResult("Home phone number must be 10 digits only.", new[] { "HomePhone" })); } HomePhone = hPhone; } if (!String.IsNullOrWhiteSpace(CellPhone)) { string cPhone = CellPhone; if (!HKValidations.HKPhoneNumberValidation(ref cPhone)) { yield return(new ValidationResult("Cell phone number must be 10 digits only.", new[] { "CellPhone" })); } HomePhone = cPhone; } } yield return(ValidationResult.Success); }
/// <summary>Compares to.</summary> /// <param name="other">The other.</param> /// <returns>System.Int32.</returns> public int CompareTo(PersonFixed other) { if (other == null) { return(1); } int result = 0; result = Address1.CompareTo(other.Address1); if (result != 0) { return(result); } result = Address2.CompareTo(other.Address2); if (result != 0) { return(result); } result = BornOn.CompareTo(other.BornOn); if (result != 0) { return(result); } result = CellPhone.CompareTo(other.CellPhone); if (result != 0) { return(result); } result = City.CompareTo(other.City); if (result != 0) { return(result); } result = Country.CompareTo(other.Country); if (result != 0) { return(result); } result = Email.CompareTo(other.Email); if (result != 0) { return(result); } result = FirstName.CompareTo(other.FirstName); if (result != 0) { return(result); } result = HomePhone.CompareTo(other.HomePhone); if (result != 0) { return(result); } result = Id.CompareTo(other.Id); if (result != 0) { return(result); } result = LastName.CompareTo(other.LastName); if (result != 0) { return(result); } result = PostalCode.CompareTo(other.PostalCode); if (result != 0) { return(result); } return(result); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { PatientsContext _context = new PatientsContext(); if (string.IsNullOrEmpty(FirstName) || FirstName == " ") { yield return(new ValidationResult("First name is a required field and cannot be blank spaces", new[] { "FirstName" })); } else { FirstName = FirstName.Trim(); FirstName = MBValidations.MBCapitalize(FirstName); } if (string.IsNullOrEmpty(LastName) || LastName == " ") { yield return(new ValidationResult("Last name is a required field and should not be blank space", new[] { "LastName" })); } else { LastName = LastName.Trim(); LastName = MBValidations.MBCapitalize(LastName); } if (string.IsNullOrEmpty(Gender) || Gender == " ") { yield return(new ValidationResult("Gender is a required field and should not start with a blank space", new[] { "Gender" })); } else { Gender = Gender.Trim(); Gender = MBValidations.MBCapitalize(Gender); } if (!string.IsNullOrEmpty(Address)) { Address = Address.Trim(); Address = MBValidations.MBCapitalize(Address); } if (!string.IsNullOrEmpty(City)) { City = City.Trim(); City = MBValidations.MBCapitalize(City); } if (!string.IsNullOrEmpty(ProvinceCode)) { ProvinceCode = ProvinceCode.Trim(); Province Pro = new Province(); string error = ""; ProvinceCode = ProvinceCode.ToUpper(); try { Pro = _context.Province.Where(m => m.ProvinceCode == ProvinceCode).FirstOrDefault(); //var country = Pro.CountryCode; } catch (Exception e) { error = e.GetBaseException().Message; } if (Pro == null) { yield return(new ValidationResult(error, new[] { nameof(ProvinceCode) })); } else { if (PostalCode != null) { PostalCode = PostalCode.Trim(); bool val = false; string USZipCode = PostalCode; if (Pro.CountryCode == "CA") { var x = Pro.FirstPostalLetter; char[] charArr = x.ToCharArray(); foreach (char ch in charArr) { if (Convert.ToChar(PostalCode.Substring(0, 1).ToUpper()) == ch) { //if(PostalCode.StartsWith(ch)) val = true; } } if (!val) { yield return(new ValidationResult("Postal code entered is not a valid code for the selected province", new[] { "PostalCode" })); } if (!MBValidations.MBPostalCodeValidation(PostalCode)) { yield return(new ValidationResult("Postal code entered is not in valid format", new[] { "PostalCode" })); } else { PostalCode = MBValidations.MBPostalCodeFormat(PostalCode); } } if (Pro.CountryCode == "US") { if (!MBValidations.MBZipCodeValidation(ref USZipCode)) { yield return(new ValidationResult("Zip code entered is not in valid format", new[] { "PostalCode" })); } else { PostalCode = USZipCode; } } } } } if (Ohip != null) { Ohip = Ohip.ToUpper(); Regex pattern = new Regex(@"^\d\d\d\d-\d\d\d-\d\d\d-[a-z][a-z]$", RegexOptions.IgnoreCase); if (!pattern.IsMatch(Ohip)) { yield return(new ValidationResult("The value for OHIP entered is not in valid format", new[] { "Ohip" })); } } if (HomePhone != null) { HomePhone = HomePhone.Trim(); if (HomePhone.Length != 10) { yield return(new ValidationResult("The Home Phone Number entered should be exactly 10 digits", new[] { "HomePhone" })); } HomePhone = HomePhone.Insert(3, "-"); HomePhone = HomePhone.Insert(7, "-"); } if (DateOfBirth != null) { if (DateOfBirth > DateTime.Now) { yield return(new ValidationResult("The date of Birth cannot be greater than current date", new[] { "DateOfBirth" })); } } if (Deceased) { if (DateOfDeath == null) { yield return(new ValidationResult("The date of death is required if the deceased checkbox is chec", new[] { "DateOfDeath" })); } } else { DateOfDeath = null; } if (DateOfDeath != null) { if (DateOfDeath > DateTime.Now || DateOfDeath < DateOfBirth) { yield return(new ValidationResult("The date of death cannot be greater than current date and before the Date of birth", new[] { "DateOfBirth" })); } } if (Gender != "M" && Gender != "F" && Gender != "X") { yield return(new ValidationResult("The value for gender entered must be M, F or X", new[] { "Gender" })); } yield return(ValidationResult.Success); }
public bool Equals(IAccount other) { if (!AccountID.Equals(other.AccountID)) { Error.AddMessage("Account " + UID + " AccountID: " + AccountID + " is not equal to other: " + other.AccountID); return(false); } if (!BirthCountry.Equals(other.BirthCountry)) { Error.AddMessage("Account " + UID + " BirthCountry: " + BirthCountry + " is not equal to other: " + other.BirthCountry); return(false); } if (!Birthday.Equals(other.Birthday)) { Error.AddMessage("Account " + UID + " Birthday: " + Birthday + " is not equal to other: " + other.Birthday); return(false); } if (!BirthPlace.Equals(other.BirthPlace)) { Error.AddMessage("Account " + UID + " BirthPlace: " + BirthPlace + " is not equal to other: " + other.BirthPlace); return(false); } if (!City.Equals(other.City)) { Error.AddMessage("Account " + UID + " City: " + City + " is not equal to other: " + other.City); return(false); } if (!Country.Equals(other.Country)) { Error.AddMessage("Account " + UID + " Country: " + Country + " is not equal to other: " + other.Country); return(false); } if (!ExtraNames.Equals(other.ExtraNames)) { Error.AddMessage("Account " + UID + " ExtraNames: " + ExtraNames + " is not equal to other: " + other.ExtraNames); return(false); } if (!Fax.Equals(other.Fax)) { Error.AddMessage("Account " + UID + " Fax: " + Fax + " is not equal to other: " + other.Fax); return(false); } if (!Gender.Equals(other.Gender)) { Error.AddMessage("Account " + UID + " Gender: " + Gender + " is not equal to other: " + other.Gender); return(false); } if (!GivenName.Equals(other.GivenName)) { Error.AddMessage("Account " + UID + " GivenName: " + GivenName + " is not equal to other: " + other.GivenName); return(false); } if (!Group.Equals(other.Group)) { Error.AddMessage("Account " + UID + " Group: " + Group + " is not equal to other: " + other.Group); return(false); } if (!HomePhone.Equals(other.HomePhone)) { Error.AddMessage("Account " + UID + " HomePhone: " + HomePhone + " is not equal to other: " + other.HomePhone); return(false); } if (!HouseNumber.Equals(other.HouseNumber)) { Error.AddMessage("Account " + UID + " HouseNumber: " + HouseNumber + " is not equal to other: " + other.HouseNumber); return(false); } if (!HouseNumberAdd.Equals(other.HouseNumberAdd)) { Error.AddMessage("Account " + UID + " HouseNumberAdd: " + HouseNumberAdd + " is not equal to other: " + other.HouseNumberAdd); return(false); } if (!Initials.Equals(other.Initials)) { Error.AddMessage("Account " + UID + " Initials: " + Initials + " is not equal to other: " + other.Initials); return(false); } if (!Mail.Equals(other.Mail)) { Error.AddMessage("Account " + UID + " Mail: " + Mail + " is not equal to other: " + other.Mail); return(false); } if (!MailAlias.Equals(other.MailAlias)) { Error.AddMessage("Account " + UID + " MailAlias: " + MailAlias + " is not equal to other: " + other.MailAlias); return(false); } if (!MobilePhone.Equals(other.MobilePhone)) { Error.AddMessage("Account " + UID + " MobilePhone: " + MobilePhone + " is not equal to other: " + other.MobilePhone); return(false); } if (!PostalCode.Equals(other.PostalCode)) { Error.AddMessage("Account " + UID + " PostalCode: " + PostalCode + " is not equal to other: " + other.PostalCode); return(false); } if (!RegisterID.Equals(other.RegisterID)) { Error.AddMessage("Account " + UID + " RegisterID: " + RegisterID + " is not equal to other: " + other.RegisterID); return(false); } if (!Role.Equals(other.Role)) { Error.AddMessage("Account " + UID + " Role: " + Role + " is not equal to other: " + other.Role); return(false); } if (!StemID.Equals(other.StemID)) { Error.AddMessage("Account " + UID + " StemID: " + StemID + " is not equal to other: " + other.StemID); return(false); } if (!Street.Equals(other.Street)) { Error.AddMessage("Account " + UID + " Street: " + Street + " is not equal to other: " + other.Street); return(false); } if (!SurName.Equals(other.SurName)) { Error.AddMessage("Account " + UID + " SurName: " + SurName + " is not equal to other: " + other.SurName); return(false); } if (!UID.Equals(other.UID)) { Error.AddMessage("Account " + UID + " UID: " + UID + " is not equal to other: " + other.UID); return(false); } if (!UntisID.Equals(other.UntisID)) { Error.AddMessage("Account " + UID + " UntisID: " + UntisID + " is not equal to other: " + other.UntisID); return(false); } return(true); }
//Validate Method public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { OECContext _context = OECContext_Singleton.Context(); //Trim all strings of leading and trailing spaces if (string.IsNullOrEmpty(Name) == false || string.IsNullOrWhiteSpace(Name)) { Name = Name.Trim(); //Use SKValidations.SKCapitalize to capitalize Name Name = SKValidations.SKCapitalize(Name); } if (Name == "") { yield return(new ValidationResult( "Name cannot be an empty string", new string[] { nameof(Name) })); } if (string.IsNullOrEmpty(Address) == false) { Address = Address.Trim(); //Use SKValidations.SKCapitalize to capitalize Address Address = SKValidations.SKCapitalize(Address); } if (string.IsNullOrEmpty(Town) == false) { Town = Town.Trim(); //Use SKValidations.SKCapitalize to capitalize Town Town = SKValidations.SKCapitalize(Town); } if (string.IsNullOrEmpty(County) == false) { County = County.Trim(); //Use SKValidations.SKCapitalize to capitalize County County = SKValidations.SKCapitalize(County); } if (string.IsNullOrEmpty(ProvinceCode) == false) { ProvinceCode = ProvinceCode.Trim(); Regex pattern = new Regex(@"^[a-zA-Z]{2}$"); //Force ProvinceCode to upper before writing to database ProvinceCode = ProvinceCode.ToUpper(); } if (string.IsNullOrEmpty(PostalCode) == false) { PostalCode = PostalCode.Trim(); } if (string.IsNullOrEmpty(HomePhone) == false) { HomePhone = HomePhone.Trim(); } if (string.IsNullOrEmpty(CellPhone) == false) { CellPhone = CellPhone.Trim(); } if (string.IsNullOrEmpty(Email) == false) { Email = Email.Trim(); } if (string.IsNullOrEmpty(Directions) == false) { Directions = Directions.Trim(); } //Either town or county must be provided, both are ok, but not necessary if (string.IsNullOrEmpty(Town) == true && string.IsNullOrEmpty(County) == true) { yield return(new ValidationResult( "At least one of Town or County must be provided.", new string[] { nameof(Town), nameof(County) })); } //If email is not provided, address and postal code must be provided if (string.IsNullOrEmpty(Email) == true && (string.IsNullOrEmpty(Address) == true || string.IsNullOrEmpty(PostalCode) == true)) { yield return(new ValidationResult( "Either email, or both address and postal code must be provided.", new string[] { nameof(Email), nameof(Address), nameof(PostalCode) })); } //Validate Postal Code var country = _context.Province.SingleOrDefault(p => p.ProvinceCode == ProvinceCode); string countryCode = country.CountryCode; bool isValid = true; string postalCode = PostalCode; //Validate Canadian Postal Code if (countryCode == "CA") { postalCode = postalCode.Trim(); isValid = SKValidations.SKPostalCodeValidation(ref postalCode); if (isValid == false) { yield return(new ValidationResult( "Postal (Zip) Code is not a valid Canadian pattern: A6A 6A6 or A6A6A6", new string[] { nameof(PostalCode) })); } else { PostalCode = postalCode; } } // Validate US Zip Code else if (countryCode == "US") { isValid = SKValidations.SKZipCodeValidation(ref postalCode); if (isValid == false) { yield return(new ValidationResult( "Postal (Zip) Code is not a valid US pattern: 12345 or 12345-1234", new string[] { nameof(PostalCode) })); } else { PostalCode = postalCode; } } //If both home and cell phone not provided if (string.IsNullOrEmpty(HomePhone) == true && string.IsNullOrEmpty(CellPhone) == true) { yield return(new ValidationResult( "Either one of Home Phone or Cell Phone is required", new string[] { nameof(HomePhone), nameof(CellPhone) })); } //If home phone provided if (string.IsNullOrWhiteSpace(HomePhone) == false) { //Extract phone number string numString = ""; foreach (char c in HomePhone) { if (char.IsDigit(c)) { numString += c; } } //Check if phone number is 10 digits long if (numString.Length != 10) { yield return(new ValidationResult( $"Not a valid phone number, must be 10 digits.", new string[] { nameof(HomePhone) })); } //Format Cell Phone number before writing to Database else { HomePhone = String.Format("{0:###-###-####}", double.Parse(numString)); } } if (string.IsNullOrWhiteSpace(CellPhone) == false) { //Check if phone number is 10 digits long string numString = ""; foreach (char c in CellPhone) { if (char.IsDigit(c)) { numString += c; } } if (numString.Length != 10) { yield return(new ValidationResult( $"Not a valid phone number, must be 10 digits.", new string[] { nameof(CellPhone) })); } //Format Cell Phone number before writing to Database else { CellPhone = String.Format("{0:###-###-####}", double.Parse(numString)); } } //Last Contact Date cannot be provided unless DateJoined is available (but the reverse is allowed) if (LastContactDate != null && DateJoined == null) { yield return(new ValidationResult( "Last Contact date cannot be provided unless Date Joined is available", new string[] { nameof(LastContactDate) })); } //A farmer cannot be contacted before they have joined the program. if (DateJoined != null && LastContactDate != null && (DateJoined > LastContactDate)) { yield return(new ValidationResult( "A farmer cannot be contacted before they have joined the program.", new string[] { nameof(LastContactDate) })); } yield return(ValidationResult.Success); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { // first name FirstName = FirstName.Trim(); FirstName = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(FirstName); // last name LastName = LastName.Trim(); LastName = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(LastName); // spouse first name SpouseFirstName = SpouseFirstName.Trim(); SpouseFirstName = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(SpouseFirstName); // spouse last name SpouseLastName = SpouseLastName.Trim(); SpouseLastName = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(SpouseLastName); if (String.IsNullOrEmpty(SpouseFirstName)) { SpouseFirstName = null; } else { SpouseFirstName = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(SpouseFirstName.Trim()); } if (String.IsNullOrEmpty(SpouseLastName)) { SpouseLastName = null; } else { SpouseLastName = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(SpouseLastName.Trim()); } // street Street = Street.Trim(); Street = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(Street); if (String.IsNullOrEmpty(Street)) { Street = null; } else { Street = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(Street.Trim()); } // city City = City.Trim(); City = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(City); if (String.IsNullOrEmpty(City)) { City = null; } else { City = HMBPClassLibrary.HMBPValidations.HMBPCapitalize(City.Trim()); } // postal code if (PostalCode == null || PostalCode == "") { PostalCode = ""; } else { PostalCode = PostalCode.Trim(); if (HMBPClassLibrary.HMBPValidations.HMBPPostalCodeValidation(PostalCode)) { PostalCode = HMBPClassLibrary.HMBPValidations.HMBPPostalCodeFormat(PostalCode); } else { string _postalCode = ""; _postalCode = PostalCode; if (HMBPClassLibrary.HMBPValidations.HMBPZipCodeValidation(ref _postalCode)) { PostalCode = _postalCode; } else { yield return(new ValidationResult("error", new[] { "PostalCode" })); } } if (ProvinceCode == null) { yield return(new ValidationResult("error", new[] { "ProvinceCode" })); } } // email if (string.IsNullOrEmpty(Email)) { Email = null; } else // trim { Email = Email.Trim(); } // comment if (string.IsNullOrEmpty(Comment)) { Comment = null; } else // trim { Comment = Comment.Trim(); } //home phone reformat HomePhone = HMBPClassLibrary.HMBPValidations.HMBPExtractDigits(HomePhone.Trim()); if (HomePhone.Length != 10) { yield return(new ValidationResult("The home phone can only contain 10 digits", new[] { nameof(HomePhone) })); } else { HomePhone = HomePhone.Insert(3, "-").Insert(7, "-"); } //validate Joined year if (YearJoined.HasValue) { if (YearJoined > DateTime.Now.Year) { YearJoined = null; yield return(new ValidationResult("The year cant be in the future", new[] { nameof(YearJoined) })); } } //Full name if (String.IsNullOrEmpty(SpouseFirstName) && String.IsNullOrEmpty(SpouseLastName)) { FullName = LastName + ", " + FirstName; } else if (!String.IsNullOrEmpty(SpouseFirstName)) { if (String.IsNullOrEmpty(SpouseLastName) || SpouseLastName == LastName) { FullName = LastName + ", " + FirstName + " & " + SpouseFirstName; } else if (!String.IsNullOrEmpty(SpouseLastName)) { FullName = LastName + ", " + FirstName + " & " + SpouseLastName + ", " + SpouseFirstName; } } yield return(ValidationResult.Success); }