public void Check_If_WebUserService_Returns_Role_Rights_Against_SqlWebUserRepository() { // Arrange IWebUserRepository userRepository = new SqlWebUserRepository(); var testLogService = new TestLogService(); IWebUserService _Repository = new WebUserService(userRepository, testLogService); //Act var studentUserInfo = _Repository.GetUserInfo(TestConstants.DbStudentUserId); var adminUserInfo = _Repository.GetUserInfo(TestConstants.DbAdminUserId); //Assert Assert.AreEqual("Student", studentUserInfo.Role); Assert.AreEqual("Admin", adminUserInfo.Role); }
public void Check_If_TestWebUserService_Returns_Correct_Role_Against_TestWebUserRepository() { // Arrange IWebUserRepository userRepository = new TestWebUserRepository(); var testLogService = new TestLogService(); IWebUserService _Repository = new WebUserService(userRepository, testLogService); //Act var studentUserInfo = _Repository.GetUserInfo(1); var adminUserInfo = _Repository.GetUserInfo(3); //Assert Assert.AreEqual("Student", studentUserInfo.Role); Assert.AreEqual("Admin", adminUserInfo.Role); }
public ActionResult ModifyReportRights(string enableReports) { try { var studentNo = Session[SessionKeyStudentNo]; IWebUserService webUserService = new WebUserService(); webUserService.UpdateReportsRight(enableReports, "Student"); // Get Admin information ... WebUser userInfo = webUserService.GetUserInfo(int.Parse(studentNo.ToString())); userInfo.WelcomeMsg = webUserService.GetWelcomeMsgText(); userInfo.RoleReportsRights = webUserService.GetRoleRights("Student"); userInfo.LoginMsg = webUserService.GetLoginMsgText(); ViewData["editOption"] = "NN"; // Record is updated. ViewData["successMsg"] = "1"; logger.Info("Report rights modification done successfully of Student No." + Session[SessionKeyStudentNo]); return(View("AdminSettings", userInfo)); } catch (Exception ex) { logger.Error("Report rights modification failded of Student No." + Session[SessionKeyStudentNo], ex); // Redirect to error page Response.Redirect("Result/error"); return(null); } }
public ActionResult ChangeLoginMsg(string txtChangeLoginMsg) { try { IWebUserService webUserService = new WebUserService(); var studentNo = Session[SessionKeyStudentNo]; webUserService.UpdateLoginMsg(txtChangeLoginMsg); // Get Admin information ... WebUser userInfo = webUserService.GetUserInfo(int.Parse(studentNo.ToString())); userInfo.WelcomeMsg = webUserService.GetWelcomeMsgText(); userInfo.RoleReportsRights = webUserService.GetRoleRights("Student"); userInfo.LoginMsg = webUserService.GetLoginMsgText(); ViewData["editOption"] = "NN"; // Record is updated. ViewData["successMsg"] = "1"; logger.Info("Welcome message changed successfully of Student No." + Session[SessionKeyStudentNo]); return(View("AdminSettings", userInfo)); } catch (Exception ex) { logger.Info("Welcome message not changed of Student No." + Session[SessionKeyStudentNo]); logger.Error(ex.Message); // Redirect to error page Response.Redirect("Result/error"); return(null); } }
private WebUser GetWebInformation() { var studentNo = Session[SessionKeyStudentNo]; IWebUserService webUserService = new WebUserService(); WebUser userInfo = webUserService.GetUserInfo(int.Parse(studentNo.ToString())); if (userInfo != null) { ISettingsService settingsService = new SettingsService(); userInfo.WelcomeMsg = settingsService.GetWelcomeMsgText(); userInfo.RoleReportsRights = webUserService.GetRoleRights("Student"); userInfo.LoginMsg = settingsService.GetLoginMsgText(); userInfo.TitleMsg = settingsService.GetTitleMsg(); userInfo.LogoFileName = settingsService.GetLogoFileName(); userInfo.EmailOrStudentId = (Int16)settingsService.GetForgetUsernameSetting(); // Set Logo file Path //var path = ConfigurationManager.AppSettings["logoPath"]; //path = Path.Combine(path, userInfo.LogoFileName); //ViewData["LogoFilePath"] = HeaderControl.imagesPath; } else { logger.Warn("User Info is null. ID is: " + studentNo); } return(userInfo); }
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 void Check_WebUser_information_Is_Successfully_get_From_Service_For_A_Valid_Db_Student() { // Arrange IWebUserService _Repository = new WebUserService(); //Act WebUser result = _Repository.GetUserInfo(DbStudentNo) as WebUser; //Assert Assert.IsNotNull(result); }
public void Change_Email_Successfully_In_Service_For_A_Valid_Db_Student() { // Get old Password IWebUserService webUserService = new WebUserService(); WebUser userInfo = webUserService.GetUserInfo(DbStudentNo); // Arrange IWebUserService _Repository = new WebUserService(); _Repository.UpdateEmail(DbStudentNo, "*****@*****.**"); // Get new password WebUser userInfoNew = webUserService.GetUserInfo(DbStudentNo); //Assert Assert.AreNotSame(userInfoNew.Email, userInfo.Email); // Revert _Repository.UpdateEmail(DbStudentNo, userInfo.Email); }
public void Change_Secret_Question_Answer_Successfully_In_SQL_Repository_For_A_Valid_Db_Student() { // Get old Password IWebUserService webUserService = new WebUserService(); WebUser userInfo = webUserService.GetUserInfo(DbStudentNo); // Arrange IWebUserRepository _Repository = new SqlWebUserRepository(); _Repository.UpdateSecretQuestionAnswer(DbStudentNo, "what your name?", "Test"); // Get new password WebUser userInfoNew = webUserService.GetUserInfo(DbStudentNo); //Assert Assert.AreNotSame(userInfoNew.SecretQuestion, userInfo.SecretQuestion); Assert.AreNotSame(userInfoNew.SecretAnswer, userInfo.SecretAnswer); // Revert _Repository.UpdateSecretQuestionAnswer(DbStudentNo, userInfo.SecretQuestion, userInfo.SecretAnswer); }
private WebUser GetStudentInfo() { IWebUserService webUserService = new WebUserService(); var studentNo = Session[SessionKeyStudentNo]; if (studentNo != null) { WebUser userInfo = webUserService.GetUserInfo(int.Parse(studentNo.ToString())); return(userInfo); } return(null); }
private WebUser GetStudentInfo() { IWebUserService webUserService = new WebUserService(); var studentNo = Session[SessionKeyStudentNo]; if (studentNo != null) { WebUser userInfo = webUserService.GetUserInfo(int.Parse(studentNo.ToString())); //userInfo.RoleReportsRights = webUserService.GetRoleRights("Student"); //userInfo.WelcomeMsg = webUserService.GetWelcomeMsgText(); return(userInfo); } return(null); }
private bool checkOldPasswordIsValid(string txtOldPassword) { IWebUserService webUserService = new WebUserService(); var studentNo = Session[SessionKeyStudentNo]; if (studentNo != null) { WebUser userInfo = webUserService.GetUserInfo(int.Parse(studentNo.ToString())); if (userInfo.WebPassword == txtOldPassword) { return(true); } } return(false); }
public ActionResult AdminSettings(string id) { var studentNo = Session[SessionKeyStudentNo]; ViewData["editOption"] = id; // Record is not updated. ViewData["successMsg"] = "0"; IWebUserService webUserService = new WebUserService(); // Get Admin information ... WebUser userInfo = webUserService.GetUserInfo(int.Parse(studentNo.ToString())); userInfo.WelcomeMsg = webUserService.GetWelcomeMsgText(); userInfo.RoleReportsRights = webUserService.GetRoleRights("Student"); userInfo.LoginMsg = webUserService.GetLoginMsgText(); return(View(userInfo)); }