private void Register_Click(object sender, EventArgs e) { if (state != ihState.Value) { // NOTE: If this is invalid, something's not right with the Facebook session... //lblSignupError.Text = "Oops, something wonky happened. Please reload the page and "; //lblSignupError.Visible = true; return; } try { var facebookUser = GetFacebookUser(); var id = facebookUser["id"].ToString(); string password = string.Empty; var person = PopulatePerson(facebookUser, CREATED_BY); person.Save(CurrentOrganization.OrganizationID, CREATED_BY, true); // Thanks again Arena! var family = new Family { OrganizationID = CurrentOrganization.OrganizationID, FamilyName = string.Format("{0} Family", person.LastName) }; family.Save(CREATED_BY); var familyMember = new FamilyMember(family.FamilyID, person.PersonID) { FamilyID = family.FamilyID, FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult) }; familyMember.Save(CREATED_BY); // Thanks Arena! var trash = person.Logins; var loginID = person.AddLogin(true, CREATED_BY, out password); // Add a PersonAttribute to their record with their Facebook ID. SavePersonAttribute(person, id, CurrentOrganization.OrganizationID); FormsAuthentication.SetAuthCookie(loginID, false); Response.Cookies["portalroles"].Value = string.Empty; Redirect(); } catch (System.Exception ex) { new ExceptionHistoryData().AddUpdate_Exception(ex, CurrentOrganization.OrganizationID, "Cccev.Web", ArenaContext.Current.ServerUrl); } }
protected int GetPersonIdFromInputData() { string sFirstName = tbFirstName.Text; string sLastName = tbLastName.Text; string sEmail = tbEmail.Text; string sAddress = tbAddress1.Text; string sCity = tbCity.Text; string sState = tbState.Text; string sZip = tbZip.Text; string sPhone = tbPhone.Text; PersonCollection personCollection = new PersonCollection(); personCollection.LoadByEmail(sEmail); int iFoundPersonId = -1; foreach (Person person in personCollection) { PersonPhone phoneSearch = new PersonPhone(person.PersonID, FormatPhone(sPhone)); if ((phoneSearch.PersonID == person.PersonID) && (person.LastName.ToLower() == sLastName.ToLower())) { this.currentAddress = person.Addresses.FindByType(41); if(this.currentAddress.Address.PostalCode.Substring(0,5) == sZip ) { iFoundPersonId = person.PersonID; } } } if (iFoundPersonId > 0) { //person in the db //easy ride... } else { //create the family for the person Family family = new Family(); family.OrganizationID = CurrentArenaContext.Organization.OrganizationID; family.FamilyName = sLastName + " Family"; //add person to the family FamilyMember familyMember = new FamilyMember(); family.FamilyMembers.Add(familyMember); // // Ensure some of the basics are set correctly. // if ((familyMember.Campus == null || familyMember.Campus.CampusId == -1) && NewPersonCampusSetting != -1) familyMember.Campus = new Campus(NewPersonCampusSetting); if (familyMember.MemberStatus == null || familyMember.MemberStatus.LookupID == -1) familyMember.MemberStatus = new Lookup(NewPersonStatusSetting); if (familyMember.RecordStatus == Arena.Enums.RecordStatus.Undefined) familyMember.RecordStatus = Arena.Enums.RecordStatus.Pending; //add person to the db familyMember.FirstName = sFirstName; familyMember.FirstName = sFirstName; familyMember.LastName = sLastName; familyMember.FamilyRole = new Lookup(new Guid("e410e1a6-8715-4bfb-bf03-1cd18051f815")); familyMember.Gender = Arena.Enums.Gender.Unknown; familyMember.MaritalStatus = new Lookup(new Guid("9C000CF2-677B-4725-981E-BD555FDAFB30")); //add email to db and person to email PersonEmail personEmail = new PersonEmail(); personEmail.Email = sEmail; personEmail.Active = true; familyMember.Emails.Add(personEmail); //add address to db and person to address PersonAddress personAddress = new PersonAddress(); personAddress.Address.StreetLine1 = sAddress; personAddress.Address.City = sCity; personAddress.Address.State = sState; personAddress.Address.PostalCode = sZip; personAddress.AddressType = new Lookup(41); personAddress.Address.Standardize(); this.currentAddress = personAddress; familyMember.Addresses.Add(personAddress); //add phone to db and person to phone PersonPhone personPhone = new PersonPhone(); personPhone.PhoneType = new Lookup(new Guid("f2a0fba2-d5ab-421f-a5ab-0c67db6fd72e")); familyMember.Phones.Add(personPhone); personPhone.Number = FormatPhone(sPhone); //Save All family.Save(ModuleUserName); familyMember.Save(CurrentOrganization.OrganizationID, ModuleUserName, true); familyMember.SaveEmails(CurrentPortal.OrganizationID, ModuleUserName); familyMember.SaveAddresses(CurrentPortal.OrganizationID, ModuleUserName); familyMember.SavePhones(CurrentPortal.OrganizationID, ModuleUserName); familyMember.Save(CurrentUser.Identity.Name); iFoundPersonId = familyMember.PersonID; } return iFoundPersonId; }
public void Save() { _model.Save(); }
private void UpdateFamily() { int organizationID = CurrentPortal.OrganizationID; string userID = CurrentUser.Identity.Name; if (userID == string.Empty) { userID = "UserConfirmation.ascx"; } bool newPerson = (person.PersonID == -1); bool newSpouse = (spouse.PersonID == -1); bool spouseUpdated = tbSpouseFirstName.Text.Trim() != string.Empty; if (NotificationEmailSetting != string.Empty && (newPerson || (newSpouse && spouseUpdated))) { SendNotification(); } else { Lookup memberStatus; try { memberStatus = new Lookup(Int32.Parse(MemberStatusIDSetting)); if (memberStatus.LookupID == -1) { throw new ModuleException(CurrentPortalPage, CurrentModule, "Member Status setting must be a valid Member Status Lookup value."); } } catch (System.Exception ex) { throw new ModuleException(CurrentPortalPage, CurrentModule, "Member Status setting must be a valid Member Status Lookup value.", ex); } if (newPerson) { person.RecordStatus = RecordStatus.Pending; person.MemberStatus = memberStatus; if (CampusSetting != string.Empty) { try { person.Campus = new Arena.Organization.Campus(Int32.Parse(CampusSetting)); } catch { person.Campus = null; } } person.MaritalStatus = new Lookup(SystemLookup.MaritalStatus_Unknown); person.Gender = Gender.Unknown; } person.FirstName = tbFirstName.Text.Trim(); person.LastName = tbLastName.Text.Trim(); Lookup HomePhoneType = new Lookup(SystemLookup.PhoneType_Home); PersonPhone HomePhone = person.Phones.FindByType(HomePhoneType.LookupID); if (HomePhone == null) { HomePhone = new PersonPhone(); HomePhone.PhoneType = HomePhoneType; person.Phones.Add(HomePhone); } HomePhone.Number = tbHomePhone.Text.Trim(); Lookup CellPhoneType = new Lookup(SystemLookup.PhoneType_Cell); PersonPhone CellPhone = person.Phones.FindByType(CellPhoneType.LookupID); if (CellPhone == null) { CellPhone = new PersonPhone(); CellPhone.PhoneType = CellPhoneType; person.Phones.Add(CellPhone); } CellPhone.Number = tbCellPhone.Text.Trim(); CellPhone.SMSEnabled = cbCellSMS.Checked; person.Emails.FirstActive = tbEmail.Text.Trim(); Lookup HomeAddressType = new Lookup(SystemLookup.AddressType_Home); PersonAddress HomeAddress = person.Addresses.FindByType(HomeAddressType.LookupID); if (HomeAddress == null) { HomeAddress = new PersonAddress(); HomeAddress.AddressType = HomeAddressType; person.Addresses.Add(HomeAddress); } HomeAddress.Address = new Address( tbStreetAddress.Text.Trim(), string.Empty, tbCity.Text.Trim(), ddlState.SelectedValue, tbZipCode.Text.Trim(), false); HomeAddress.Primary = true; person.Save(organizationID, userID, false); person.SaveAddresses(organizationID, userID); person.SavePhones(organizationID, userID); person.SaveEmails(organizationID, userID); if (spouseUpdated) { if (newSpouse) { spouse.RecordStatus = RecordStatus.Pending; spouse.MemberStatus = memberStatus; if (CampusSetting != string.Empty) { try { spouse.Campus = new Arena.Organization.Campus(Int32.Parse(CampusSetting)); } catch { spouse.Campus = null; } } spouse.MaritalStatus = new Lookup(SystemLookup.MaritalStatus_Married); person.MaritalStatus = spouse.MaritalStatus; spouse.Gender = Gender.Unknown; } spouse.FirstName = tbSpouseFirstName.Text.Trim(); spouse.LastName = tbSpouseLastName.Text.Trim(); PersonPhone SpouseHomePhone = spouse.Phones.FindByType(HomePhoneType.LookupID); if (SpouseHomePhone == null) { SpouseHomePhone = new PersonPhone(); SpouseHomePhone.PhoneType = HomePhoneType; spouse.Phones.Add(SpouseHomePhone); } SpouseHomePhone.Number = tbSpouseHomePhone.Text.Trim(); PersonPhone SpouseCellPhone = spouse.Phones.FindByType(CellPhoneType.LookupID); if (SpouseCellPhone == null) { SpouseCellPhone = new PersonPhone(); SpouseCellPhone.PhoneType = CellPhoneType; spouse.Phones.Add(SpouseCellPhone); } SpouseCellPhone.Number = tbSpouseCellPhone.Text.Trim(); SpouseCellPhone.SMSEnabled = cbSpouseSMS.Checked; spouse.Emails.FirstActive = tbSpouseEmail.Text.Trim(); spouse.Save(organizationID, userID, false); spouse.SaveAddresses(organizationID, userID); spouse.SavePhones(organizationID, userID); spouse.SaveEmails(organizationID, userID); } if (newPerson) { Family family = new Family(); family.OrganizationID = organizationID; family.FamilyName = tbLastName.Text.Trim() + " Family"; family.Save(userID); FamilyMember fm = new FamilyMember(family.FamilyID, person.PersonID); fm.FamilyID = family.FamilyID; fm.FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult); fm.Save(userID); if (spouseUpdated) { fm = new FamilyMember(family.FamilyID, spouse.PersonID); fm.FamilyID = family.FamilyID; fm.FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult); fm.Save(userID); } } } if (iRedirect.Value.Trim() != string.Empty) { StringBuilder sbRedirect = new StringBuilder(); sbRedirect.Append(iRedirect.Value.Trim()); sbRedirect.Append("&confirmed=true"); // If this is a new person, the person object needs to be reloaded to get new GUID if (newPerson) { person = new Person(person.PersonID); } sbRedirect.AppendFormat("&person={0}", person.PersonGUID.ToString()); if (spouseUpdated) { if (newSpouse) { spouse = new Person(spouse.PersonID); } sbRedirect.AppendFormat("&spouse={0}", spouse.PersonGUID.ToString()); } Response.Redirect(sbRedirect.ToString(), true); } }
private void CreateAccount() { Arena.Security.Login login; string loginID; if (CustomLoginSetting == true) { // Ensure that login ID is unique loginID = tbLoginID.Text; login = new Arena.Security.Login(loginID); if (login.PersonID != -1) { int loginCount = 0; loginID = tbFirstName.Text.Substring(0, 1).ToLower() + tbLastName.Text.Trim().ToLower(); if (loginID != loginID.ToLower()) { login = new Arena.Security.Login(loginID); } while (login.PersonID != -1) { loginCount++; login = new Arena.Security.Login(loginID + loginCount.ToString()); } lblMessage.Text = "The Desired Login ID you selected is already in use in our system. Please select a different Login ID. Suggestion: <b>" + loginID + loginCount.ToString() + "</b>"; pnlMessage.Visible = true; lblMessage.Visible = true; return; } } else { Int32 loginCount = 0; // // Construct a login Id that can be used. // do { if (loginCount == 0) { loginID = tbFirstName.Text + " " + tbLastName.Text; } else { loginID = tbFirstName.Text + " " + tbLastName.Text + loginCount.ToString(); } loginID = loginID.ToLower(); login = new Arena.Security.Login(loginID); loginCount++; } while (login.PersonID != -1); } Lookup memberStatus; try { memberStatus = new Lookup(Int32.Parse(MemberStatusIDSetting)); if (memberStatus.LookupID == -1) { throw new ModuleException(CurrentPortalPage, CurrentModule, "Member Status setting must be a valid Member Status Lookup value."); } } catch (System.Exception ex) { throw new ModuleException(CurrentPortalPage, CurrentModule, "Member Status setting must be a valid Member Status Lookup value.", ex); } int organizationID = CurrentPortal.OrganizationID; string userID = CurrentUser.Identity.Name; if (userID == string.Empty) { userID = "NewAccount.ascx"; } Person person = new Person(); person.RecordStatus = RecordStatus.Pending; person.MemberStatus = memberStatus; if (CampusSetting != string.Empty) { try { person.Campus = new Arena.Organization.Campus(Int32.Parse(CampusSetting)); } catch { person.Campus = null; } } person.FirstName = tbFirstName.Text.Trim(); person.LastName = tbLastName.Text.Trim(); if (tbBirthDate.Text.Trim() != string.Empty) { try { person.BirthDate = DateTime.Parse(tbBirthDate.Text); } catch { } } if (ddlMaritalStatus.SelectedValue != string.Empty) { person.MaritalStatus = new Lookup(Int32.Parse(ddlMaritalStatus.SelectedValue)); } if (ddlGender.SelectedValue != string.Empty) { try { person.Gender = (Gender)Enum.Parse(typeof(Gender), ddlGender.SelectedValue); } catch { } } PersonAddress personAddress = new PersonAddress(); personAddress.Address = new Address( tbStreetAddress.Text.Trim(), string.Empty, tbCity.Text.Trim(), ddlState.SelectedValue, tbZipCode.Text.Trim(), false); personAddress.AddressType = new Lookup(SystemLookup.AddressType_Home); personAddress.Primary = true; person.Addresses.Add(personAddress); PersonPhone phone = new PersonPhone(); phone.Number = tbHomePhone.PhoneNumber.Trim(); phone.PhoneType = new Lookup(SystemLookup.PhoneType_Home); person.Phones.Add(phone); if (tbWorkPhone.PhoneNumber.Trim() != string.Empty) { phone = new PersonPhone(); phone.Number = tbWorkPhone.PhoneNumber.Trim(); phone.Extension = tbWorkPhone.Extension; phone.PhoneType = new Lookup(SystemLookup.PhoneType_Business); person.Phones.Add(phone); } if (tbCellPhone.PhoneNumber.Trim() != string.Empty) { phone = new PersonPhone(); phone.Number = tbCellPhone.PhoneNumber.Trim(); phone.PhoneType = new Lookup(SystemLookup.PhoneType_Cell); phone.SMSEnabled = cbSMS.Checked; person.Phones.Add(phone); } if (tbEmail.Text.Trim() != string.Empty) { PersonEmail personEmail = new PersonEmail(); personEmail.Active = true; personEmail.Email = tbEmail.Text.Trim(); person.Emails.Add(personEmail); } person.Save(organizationID, userID, false); person.SaveAddresses(organizationID, userID); person.SavePhones(organizationID, userID); person.SaveEmails(organizationID, userID); Family family = new Family(); family.OrganizationID = organizationID; family.FamilyName = tbLastName.Text.Trim() + " Family"; family.Save(userID); FamilyMember fm = new FamilyMember(family.FamilyID, person.PersonID); fm.FamilyID = family.FamilyID; fm.FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult); fm.Save(userID); Arena.Security.Login personLogin = new Arena.Security.Login(); personLogin.PersonID = person.PersonID; personLogin.LoginID = loginID; personLogin.Password = tbPassword.Text.Trim(); personLogin.Active = true; personLogin.Save(userID); // Use security system to set the UserID within a client-side Cookie FormsAuthentication.SetAuthCookie(personLogin.LoginID, false); Response.Cookies["portalroles"].Value = string.Empty; if (ProfileIDSetting != string.Empty) { int profileID = -1; int sourceLUID = -1; int statusLUID = -1; try { if (ProfileIDSetting.Contains("|")) { profileID = Int32.Parse(ProfileIDSetting.Split('|')[1]); } else { profileID = Int32.Parse(ProfileIDSetting); } sourceLUID = Int32.Parse(SourceLUIDSetting); statusLUID = Int32.Parse(StatusLUIDSetting); } catch (System.Exception ex) { throw new ModuleException(CurrentPortalPage, CurrentModule, "If using a ProfileID setting for the NewAccount module, " + "then a valid numeric 'ProfileID', 'SourceLUID', and 'StatusLUID' setting must all be used!", ex); } Profile profile = new Profile(profileID); Lookup sourceLu = new Lookup(sourceLUID); Lookup statusLu = new Lookup(statusLUID); if (profile.ProfileID != -1 && sourceLu.LookupID != -1 && statusLu.LookupID != -1) { ProfileMember profileMember = new ProfileMember(); profileMember.ProfileID = profile.ProfileID; profileMember.PersonID = person.PersonID; profileMember.Source = sourceLu; profileMember.Status = statusLu; profileMember.DatePending = DateTime.Now; profileMember.Save(userID); if (profile.ProfileType == ProfileType.Serving) { ServingProfile sProfile = new ServingProfile(profile.ProfileID); ServingProfileMember sMember = new ServingProfileMember(profileMember.ProfileID, profileMember.PersonID); sMember.HoursPerWeek = sProfile.DefaultHoursPerWeek; sMember.Save(); } } else { throw new ModuleException(CurrentPortalPage, CurrentModule, "'ProfileID', 'SourceLUID', and 'StatusLUID' must all be valid IDs"); } } // // If we are letting the user pick their own login ID then just redirect // the browser back to the originating page. Otherwise put up some text to // tell the user what their new login ID is. // if (CustomLoginSetting == true) { Response.Redirect(iRedirect.Value); } else { pnlCreateAccount.Visible = false; lbLoginCreated.Text = "Your account has been created. Your login ID is \"" + loginID + "\".<BR /><BR />You may use this login ID the next time you visit this site.<BR />"; pnlLoginCreated.Visible = true; } }