protected void Page_Load( object sender, EventArgs e ) { if ( !IsPostBack ) { Person person; string personId = ( string )Page.RouteData.Values["PersonId"] ?? string.Empty; if ( string.IsNullOrEmpty( personId ) ) personId = Request.QueryString["PersonId"]; PersonService personService = new PersonService(); if ( !string.IsNullOrEmpty( personId ) ) person = personService.Get( Convert.ToInt32( personId ) ); else { person = new Person(); personService.Add( person, CurrentPersonId ); } txtFirstName.Text = person.FirstName; txtNickName.Text = person.NickName; txtLastName.Text = person.LastName; } }
protected void btnUpdate_Click( object sender, EventArgs e ) { if ( Page.IsValid ) { Person person; string personId = ( string )Page.RouteData.Values["PersonId"] ?? string.Empty; if ( string.IsNullOrEmpty( personId ) ) personId = Request.QueryString["PersonId"]; PersonService personService = new PersonService(); if ( !string.IsNullOrEmpty( personId ) ) person = personService.Get( Convert.ToInt32( personId ) ); else { person = new Person(); personService.Add( person, CurrentPersonId ); } person.GivenName = txtFirstName.Text; person.NickName = txtNickName.Text; person.LastName = txtLastName.Text; if ( person.Guid == Guid.Empty ) personService.Add( person, CurrentPersonId ); personService.Save( person, CurrentPersonId ); } }
private void DisplaySuccess( Rock.CMS.User user ) { FormsAuthentication.SignOut(); FormsAuthentication.SetAuthCookie( tbUserName.Text, false ); if ( user != null && user.PersonId.HasValue ) { PersonService personService = new PersonService(); Person person = personService.Get( user.PersonId.Value ); if ( person != null ) { var mergeObjects = new List<object>(); mergeObjects.Add( person ); mergeObjects.Add( user ); var values = new Dictionary<string, string>(); values.Add( "ConfirmAccountUrl", RootPath + "ConfirmAccount" ); mergeObjects.Add( values ); var recipients = new Dictionary<string, List<object>>(); recipients.Add( person.Email, mergeObjects ); Email email = new Email( Rock.SystemGuid.EmailTemplate.SECURITY_ACCOUNT_CREATED ); SetSMTPParameters( email ); email.Send( recipients ); lSuccessCaption.Text = AttributeValue( "SuccessCaption" ); if ( lSuccessCaption.Text.Contains( "{0}" ) ) lSuccessCaption.Text = string.Format( lSuccessCaption.Text, person.FirstName ); ShowPanel( 5 ); } else ShowErrorMessage( "Invalid Person" ); } else ShowErrorMessage( "Invalid User" ); }
private void DisplaySentLogin( Direction direction ) { using ( new Rock.Data.UnitOfWorkScope() ) { PersonService personService = new PersonService(); Rock.CMS.UserService userService = new Rock.CMS.UserService(); Person person = personService.Get( Int32.Parse( hfSendPersonId.Value ) ); if ( person != null ) { var mergeObjects = new List<object>(); var values = new Dictionary<string, string>(); values.Add( "ConfirmAccountUrl", RootPath + "ConfirmAccount" ); mergeObjects.Add( values ); Dictionary<object, List<object>> personObjects = new Dictionary<object, List<object>>(); var userObjects = new List<object>(); mergeObjects.Add( person ); foreach ( var user in userService.GetByPersonId( person.Id ) ) if (user.AuthenticationType != Rock.CMS.AuthenticationType.Facebook) userObjects.Add( user ); personObjects.Add( person, userObjects ); mergeObjects.Add(personObjects); var recipients = new Dictionary<string, List<object>>(); recipients.Add(person.Email, mergeObjects); Email email = new Email( Rock.SystemGuid.EmailTemplate.SECURITY_FORGOT_USERNAME ); SetSMTPParameters( email ); email.Send( recipients ); } else ShowErrorMessage( "Invalid Person" ); } ShowPanel( 3 ); }
private void DisplaySendLogin( int personId, Direction direction ) { hfSendPersonId.Value = personId.ToString(); lExistingAccountCaption.Text = AttributeValue( "ExistingAccountCaption" ); if ( lExistingAccountCaption.Text.Contains( "{0}" ) ) { PersonService personService = new PersonService(); Person person = personService.Get( personId ); if ( person != null ) lExistingAccountCaption.Text = string.Format( lExistingAccountCaption.Text, person.FirstName ); } ShowPanel( 2 ); }
private void DisplayConfirmation( int personId ) { PersonService personService = new PersonService(); Person person = personService.Get(personId); if (person != null) { Rock.CMS.User user = CreateUser( person, false ); var mergeObjects = new List<object>(); mergeObjects.Add( person ); mergeObjects.Add( user ); var values = new Dictionary<string, string>(); values.Add( "ConfirmAccountUrl", RootPath + "ConfirmAccount" ); mergeObjects.Add( values ); var recipients = new Dictionary<string, List<object>>(); recipients.Add( person.Email, mergeObjects ); Email email = new Email( Rock.SystemGuid.EmailTemplate.SECURITY_CONFIRM_ACCOUNT ); SetSMTPParameters( email ); email.Send( recipients ); ShowPanel( 4 ); } else ShowErrorMessage("Invalid Person"); }