Exemplo n.º 1
0
        public int ChangePasswordfun(Int64 userid, string currentpassword, string newpassword, int pwdCount)
        {
            //  1-PASS 2 INVALID CURRENTPASSWORD 3 ALREADY USED
            int   count = 0;
            Int64 pwdHistoryId;

            try
            {
                UserLogonData userLogonData = new UserLogonData();

                PasswordHistory pwdHis = new PasswordHistory();
                pwdHis.pwdHistory = userLogonData.GetPasswordHistory(userid);



                if (pwdHis.pwdHistory.Count >= pwdCount)
                {
                    pwdHistoryId = Int64.Parse(pwdHis.pwdHistory[0].Ph_Id.ToString());
                }
                else
                {
                    pwdHistoryId = 0;
                }

                count = (from b in pwdHis.pwdHistory
                         where b.DBPassword == newpassword
                         select b).Count();

                if (count > 0)
                {
                    return(3);
                }
                else
                {
                    if (userLogonData.UpdatePassword(userid, newpassword, pwdHistoryId) == true)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }