/// <summary> /// Updates password /// </summary> /// <param name="oldUser"></param> /// <param name="newUser"></param> /// <returns></returns> public static bool UpdatePassword(UserSecurity oldUser, UserSecurity newUser) { string updateCommand = "UPDATE UserSecurity SET " + "Password = @newPassword " + "WHERE UserName = @oldUserName AND " + "Password = @oldPassword"; try { using (SqlConnection connection = new SqlConnection()) { connection.Open(); using (SqlCommand cmnd = new SqlCommand(updateCommand, connection)) { cmnd.Parameters.AddWithValue("@newPassword", newUser.Password); cmnd.Parameters.AddWithValue("@oldUserName", oldUser.UserName); cmnd.Parameters.AddWithValue("@oldPassword", oldUser.Password); int count = cmnd.ExecuteNonQuery(); if (count > 0) { return true; } else { return false; } } } } catch (SqlException ex) { throw ex; } catch (Exception ex) { throw ex; } }
/// <summary> /// Updates the password /// </summary> /// <param name="oldUser">old password</param> /// <param name="newUser">new password</param> /// <returns>true if successful</returns> public static bool UpdatePassword(UserSecurity oldUser, UserSecurity newUser) { return UserSecurityDAL.UpdatePassword(oldUser, newUser); }