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); } }
/// <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 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 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 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", EmailAddress); p.UpdateValue(psb, "EmailAddress2", EmailAddress2); p.UpdateValue(psb, "SendEmailAddress1", SendEmailAddress1); p.UpdateValue(psb, "SendEmailAddress2", SendEmailAddress2); p.UpdateValue(psb, "ReceiveSMS", ReceiveSMS); p.UpdateValue(psb, "FirstName", First); p.UpdateValue(psb, "LastName", Last); p.UpdateValue(psb, "AltName", AltName); p.UpdateValue(psb, "GenderId", GenderId); p.UpdateValue(psb, "Grade", Grade.ToInt2()); p.UpdateValue(psb, "CellPhone", CellPhone.GetDigits()); p.Family.UpdateValue(fsb, "HomePhone", HomePhone.GetDigits()); p.UpdateValue(psb, "MaidenName", Maiden); p.UpdateValue(psb, "MaritalStatusId", MaritalStatusId); p.UpdateValue(psb, "MiddleName", Middle); p.UpdateValue(psb, "NickName", NickName); 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); p.UpdateValue(psb, "WeddingDate", WeddingDate); p.UpdateValue(psb, "WorkPhone", WorkPhone.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, First + " " + Last, PeopleId, psb.ToString(), fsb.ToString())); } } }