public string CreateUser(string userName, string password, string confirmPassword, string email, string fullName, string contactNo) { string returnMessage = ""; //if (userName.Length < 0 || password.Length < 0 || email.Length < 0 || fullName.Length < 0 || contactNo.Length < 0) //{ // returnMessage = "Please enter all fields."; //} if (userName.Length > 120) returnMessage += "UserName exceeds 120 characters!<br />"; if (userName.Length == 0) returnMessage += "Please enter an username.<br />"; if (password.Length > 120) returnMessage += "Password exceeds 120 characters!<br />"; if (password.Length == 0) returnMessage += "Please enter a password.<br />"; if (password != confirmPassword) returnMessage += "Passwords do not match. Please try again.<br />"; if (email.Length > 120) returnMessage += "Email exceeds 120 characters!<br />"; if (email.Length == 0) returnMessage += "Please enter an email.<br />"; if (fullName.Length > 120) returnMessage += "Name exceeds 120 characters!<br />"; if (fullName.Length == 0) returnMessage += "Please enter your name.<br />"; if (contactNo.Length != 8) returnMessage += "Contact Number needs to be 8 digits!<br />"; if (returnMessage.Length == 0) { //No error; proceed UserDAL userdal = new UserDAL(userName, password, email, fullName, contactNo); //int nofRows = 0; //nofRows = userdal.UserInsert(); //if (nofRows > 0) // returnMessage = "User record saved successfully."; //else // returnMessage = "Unable to save user record. Please try again."; userdal.UserInsert(); returnMessage = "User record saved successfully."; } return returnMessage; }
public string UpdateUser(string password, string confirmPassword, string contactNo) { string returnMessage = ""; if (password.Length > 120) returnMessage += "Password exceeds 120 characters!<br />"; if (password.Length == 0) returnMessage += "Please enter a password.<br />"; if (password != confirmPassword) returnMessage += "Both new passwords do not match. Please try again.<br />"; if (contactNo.Length != 8) returnMessage += "Contact Number needs to be 8 integers!<br />"; if (returnMessage.Length == 0) { //proceed if no error UserDAL user = new UserDAL(password, contactNo); int nofRows = 0; nofRows = user.UserUpdate(); if (nofRows > 0) returnMessage = "User record updated successfully."; else returnMessage = "Unable to update user record. Please try again."; } return returnMessage; }