Rock.Model.UserLoginService.GetByUserName C# (CSharp) Метод

GetByUserName() публичный Метод

GetsRock.Model.UserLogin by User Name
public GetByUserName ( string userName ) : UserLogin
userName string A representing the UserName to search for.
Результат UserLogin
        public UserLogin GetByUserName( string userName )
        {
            return Queryable( "Person.Aliases" )
                .Where( u => u.UserName == userName )
                .FirstOrDefault();
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Handles the Click event of the btnChange control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnChange_Click( object sender, EventArgs e )
        {
            var userLoginService = new UserLoginService();
            var userLogin = userLoginService.GetByUserName( tbUserName.Text );
            if ( userLogin != null )
            {
                if ( UserLoginService.IsPasswordValid( tbPassword.Text ) )
                {
                    if ( userLoginService.ChangePassword( userLogin, tbOldPassword.Text, tbPassword.Text ) )
                    {
                        userLoginService.Save( userLogin, CurrentPersonId );

                        lSuccess.Text = GetAttributeValue( "SuccessCaption" );
                        pnlEntry.Visible = false;
                        pnlSuccess.Visible = true;
                    }
                    else
                        DisplayError( "InvalidPasswordCaption" );
                }
                else
                {
                    InvalidPassword();
                }
            }
            else
                DisplayError( "InvalidUserNameCaption" );
        }
All Usage Examples Of Rock.Model.UserLoginService::GetByUserName