public void Change_Password_Successfully_Service_For_A_Valid_Db_Student() { // Get old Password IWebUserService webUserService = new WebUserService(); WebUser userInfo = webUserService.GetUserInfo(DbStudentNo); // Arrange IWebUserService _Repository = new WebUserService(); _Repository.UpdatePassword(DbStudentNo, "Test"); // Get new password WebUser userInfoNew = webUserService.GetUserInfo(DbStudentNo); //Assert Assert.AreNotSame(userInfoNew.WebPassword, userInfo.WebPassword); // Revert _Repository.UpdatePassword(DbStudentNo, userInfo.WebPassword); }
public ActionResult ChangePassword(FormCollection collection) { string txtOldPassword = collection["txtOldPassword"]; string txtNewPassword = collection["txtNewPassword"]; try { if (CheckOldPasswordIsValid(txtOldPassword)) { IWebUserService webUserService = new WebUserService(); var studentNo = Session[SessionKeyStudentNo]; webUserService.UpdatePassword(int.Parse(studentNo.ToString()), txtNewPassword); // Get Student information ... var userInfo = GetStudentInfo(); ViewData["editOption"] = "cp"; // Record is updated. ViewData["successMsg"] = "1"; logger.Debug("Password was successfully changed for Student No." + Session[SessionKeyStudentNo]); return(View("UserSettings", userInfo)); } else { // Get Student information ... var userInfo = GetStudentInfo(); ViewData["editOption"] = "cp"; // Old password not match ViewData["oldPassword"] = "******"; logger.Info("Old password not match of student No. " + Session[SessionKeyStudentNo]); return(View("UserSettings", userInfo)); } } catch (Exception ex) { logger.Error("Password change request failed for Student No." + Session[SessionKeyStudentNo], ex); // Redirect to error page Response.Redirect(AppHelper.SharedUrl("Reply/Error")); return(null); } }
public ActionResult ChangePassword(string txtOldPassword, string txtNewPassword) { try { if (checkOldPasswordIsValid(txtOldPassword)) { IWebUserService webUserService = new WebUserService(); var studentNo = Session[SessionKeyStudentNo]; webUserService.UpdatePassword(int.Parse(studentNo.ToString()), txtNewPassword); // Get Student information ... var userInfo = GetStudentInfo(); ViewData["editOption"] = "cp"; // Record is updated. ViewData["successMsg"] = "1"; logger.Info("Password changed successfully of Student No." + Session[SessionKeyStudentNo]); return(View("UserSettings", userInfo)); } else { // Get Student information ... var userInfo = GetStudentInfo(); ViewData["editOption"] = "cp"; // Old password not match ViewData["oldPassword"] = "******"; logger.Info("Old password not match of student No. " + Session[SessionKeyStudentNo]); return(View("UserSettings", userInfo)); } } catch (Exception ex) { logger.Error("Password changed failed of Student No." + Session[SessionKeyStudentNo], ex); // Redirect to error page Response.Redirect("Result/error"); return(null); } }