protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value != null)
            {
                NewPassword lgc = (NewPassword)validationContext.ObjectInstance;

                bool          Success = false;
                SqlConnection conn    = new SqlConnection(ConnString.Value);
                SqlCommand    cmd     = new SqlCommand();
                SqlDataReader dr;
                try
                {
                    cmd.CommandText = "SELECT inetpwd FROM sapvendors_pers pers LEFT JOIN sapvendors vend ON pers.num=vend.num WHERE pers.inetname=@Inetname AND vend.xactive=1";
                    cmd.Parameters.Add("@Inetname", SqlDbType.Char).Value = Strings.Encrypt(CurrentUser.InetName);
                    cmd.Connection = conn;
                    cmd.Connection.Open();
                    dr = cmd.ExecuteReader();
                    if (dr.Read() && dr.HasRows)
                    {
                        //Get Function
                        string PwdFromDb    = dr[0].ToString().Trim();
                        string PwdFromInput = lgc.Password1.Trim();
                        if (PwdFromDb.Length == 139 && PwdFromDb.Substring(128, 1) == "$")
                        {
                            Success = !(Strings.SHA512(PwdFromInput + Strings.Right(PwdFromDb, 10)).ToLower() == Strings.Left(PwdFromDb, 128));
                        }
                    }
                    dr.Close();
                    cmd.Dispose();
                }
                catch
                {
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }

                if (Success)
                {
                    return(ValidationResult.Success);
                }
                else
                {
                    var errorMessage = FormatErrorMessage(validationContext.DisplayName);
                    return(new ValidationResult(errorMessage));
                }
            }
            else
            {
                return(ValidationResult.Success);
            }
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value != null)
            {
                NewPassword lgc = (NewPassword)validationContext.ObjectInstance;

                if (lgc.Password1.Trim() == lgc.Password2.Trim())
                {
                    return(ValidationResult.Success);
                }
                else
                {
                    var errorMessage = FormatErrorMessage(validationContext.DisplayName);
                    return(new ValidationResult(errorMessage));
                }
            }
            else
            {
                return(ValidationResult.Success);
            }
        }
        public PasswordChangeModel(IHtmlLocalizerFactory htmlLocalizerFactory)
        {
            _loc = htmlLocalizerFactory.Create(Includes.AppShortName + ".Pages.Index", Includes.AppShortName);

            NewPwd = new NewPassword();
        }