//public bool IsValidPassword(PasswordFM passwordFM) //{ // UserDAO dao = new UserDAO(); // if (passwordFM.Password != null && passwordFM.Password.Length > 5 && dao.GetUserByEmail(passwordFM.Password) == null) // { // return true; // } // return false; //} public PasswordFM GetPasswordFM(int ID) { UserDAO dao = new UserDAO(); User user = dao.GetUserByID(ID); PasswordFM passwordFM = new PasswordFM(user); return passwordFM; }
public UserFM GetUserFM(int ID) { UserDAO dao = new UserDAO(); User user = dao.GetUserByID(ID); UserFM userFM = new UserFM(user); return userFM; }
public bool IsValidUser(UserFM userFM) { UserDAO dao = new UserDAO(); if(userFM.Email != null && userFM.Email.Length > 5 && dao.GetUserByEmail(userFM.Email) == null) { return true; } return false; }
public LoginVM Login(LoginFM login) { LoginVM userVM = null; UserDAO dao = new UserDAO(); User user = dao.GetUserByEmail(login.Email); if(user != null && user.Password == login.Password) { userVM = new LoginVM(); userVM.Email = user.Email; userVM.ID = user.ID; } return userVM; }
public UsersVM GetUsers() { UserDAO dao = new UserDAO(); List<User> users = dao.GetAllUsers(); UsersVM usersVM = new UsersVM(); foreach(User user in users) { UserVM userVM = new UserVM(); userVM.UserID = user.ID; userVM.Email = user.Email; usersVM.Users.Add(userVM); } return usersVM; }
//public User ConvertUser(UserFM user) //{ // User userDAO = new User(); // userDAO.Email = user.Email; //} public bool CreateUser(UserFM userFM) { if (IsValidUser(userFM)) { //email temp pass to user UserDAO dao = new UserDAO(); User user = new User(); user.Email = userFM.Email; user.Password = RandomPassword(); dao.CreateUser(user); return true; } return false; }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { // Determine the currently logged on user's UserId //MembershipUser currentUser = Membership.GetUser(); //Guid currentUserId = (Guid)currentUser.ProviderUserKey; //Create user in Account table DAO_Account_Interface acc_ctx = new AccountDAO(); AccountDTO newAccount = new AccountDTO(); newAccount.userName = CreateUserWizard1.UserName.ToLower(); newAccount.password = "******"; newAccount.status = "active"; newAccount.accountType = "user"; acc_ctx.presist(newAccount); //Add User Email to COntact Info DAO_ContactInfo_Interface info_ctx = new ContactInfoDAO(); ContactInfoDTO mail_info = new ContactInfoDTO(); mail_info.userName = newAccount.userName; mail_info.contactType = "e-mail"; mail_info.data = CreateUserWizard1.Email; info_ctx.presist(mail_info); //Add User information to User Table DAO_User_Interface user_ctx = new UserDAO(); UserDTO user_info = new UserDTO(); user_info.userName = newAccount.userName; user_info.id = txtID.Text; user_info.fullName = txtName.Text; user_info.surname = txtSurname.Text; user_info.nickName = txtNickname.Text; user_info.idType = RadioIdType.SelectedValue; user_info.race = RadioRace.SelectedValue; user_info.gender = RadioGender.SelectedValue; user_ctx.presist(user_info); Roles.AddUserToRole(newAccount.userName, "User"); }
public void UpdateUser(UserFM userFM) { UserDAO dao = new UserDAO(); User user = dao.GetUserByID(userFM.ID); user.Email = userFM.Email; dao.UpdateUser(user); }
public void UpdatePassword(PasswordFM passwordFM) { UserDAO dao = new UserDAO(); User user = dao.GetUserByID(passwordFM.ID); user.Password = passwordFM.NewPassword; dao.UpdateUser(user); }
public void DeleteUser(int ID) { UserDAO dao = new UserDAO(); dao.DeleteUser(ID); }
// create a method to view all users public List <UserDAO> ViewAllUsers() { // create a new instance of userDAO List <UserDAO> _UserList = new List <UserDAO>(); // set the bool to false bool success = false; // create try catch to catch any possible errors try { // create a using statment to use the connection string using (SqlConnection _Connection = new SqlConnection(connectionString)) { // create using statment to specify the stored procedure using (SqlCommand _Command = new SqlCommand("sp_UserAccountInfoViewAllUsers", _Connection)) { // specify the command is a stored procedure _Command.CommandType = System.Data.CommandType.StoredProcedure; // open the connection _Connection.Open(); // create a using statement using the reader to reader through the list using (SqlDataReader _Reader = _Command.ExecuteReader()) { // create a while loop to read throught the whole record while (_Reader.Read()) { // create a new instance of userDOA to retrieve each item UserDAO userToList = new UserDAO(); // get the user elements userToList.accountInfoID = Convert.ToInt32(_Reader["accountInfoID"]); userToList.userTableID = Convert.ToInt32(_Reader["userTableID"]); userToList.accountFirstName = (string)_Reader["accountFirstName"]; userToList.accountLastName = (string)_Reader["accountLastName"]; userToList.accountEmail = (string)_Reader["accountEmail"]; userToList.accountPhoneNumber = (string)_Reader["accountPhoneNumber"]; userToList.accountAddress = (string)_Reader["accountAddress"]; userToList.accountCity = (string)_Reader["accountCity"]; userToList.accountState = (string)_Reader["accountState"]; userToList.accountZip = Convert.ToInt32(_Reader["accountZip"]); userToList.roleName = (string)_Reader["roleName"]; _UserList.Add(userToList); } } //change the bool to true success = true; //close the connection _Connection.Close(); } } } catch (Exception error) { // call the error method and pass the error ErrorMessage.logger(error); } return(_UserList); }