protected void btnSubscribe_Click(object sender, EventArgs e) { txtFirstName.Text = txtFirstName.Text.Trim(); txtLastName.Text = txtLastName.Text.Trim(); txtEmail.Text = txtEmail.Text.Trim().ToLower(); PhotoMembershipProvider membershipProvider = new PhotoMembershipProvider(); string password = membershipProvider.GeneratePassword(); UserInfo newUser = UserController.Create(txtFirstName.Text, txtLastName.Text, txtEmail.Text, password, txtEmail.Text, null, null); try { EmailHelper.WelcomeUserEmail(newUser, password); } catch (Exception ex) { LogHelper.Log(Logger.Application, LogLevel.Error, "Failed to sent email to the user. \n" + ex.Message); return; } if (newUser == null) { throw new Exception("Could not create user"); } Response.Redirect("Default.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { txtFirstNameEN.Text = txtFirstNameEN.Text.Trim(); txtLastNameEN.Text = txtLastNameEN.Text.Trim(); txtEmail.Text = txtEmail.Text.Trim().ToLower(); List <RoleInfo> roles = new List <RoleInfo>(); if (UserToEdit != null) { foreach (RoleInfo notselectedRole in RoleController.Instance.All) { RoleController.Instance.RemoveUserFromRole(UserToEdit, notselectedRole); } } foreach (ListItem item in chkRoleList.Items) { if (item.Selected) { RoleInfo role = RoleController.Instance.GetRoleByName(item.Value); if (role != null) { roles.Add(role); } } } if (UserToEdit != null) { foreach (RoleInfo selectedRole in roles) { RoleController.Instance.AddUserToRole(UserToEdit, selectedRole); } UserToEdit.FirstNameEN = txtFirstNameEN.Text; UserToEdit.LastNameEN = txtLastNameEN.Text; UserController.Update(UserToEdit); } else { PhotoMembershipProvider membershipProvider = new PhotoMembershipProvider(); string password = membershipProvider.GeneratePassword(); UserInfo newUser = UserController.Create(txtFirstNameEN.Text, txtLastNameEN.Text, txtEmail.Text, password, txtEmail.Text, roles, null); if (_targetEnvironment != Target.Development) { EmailHelper.WelcomeUserEmail(newUser, password); } if (newUser == null) { throw new Exception("Could not create user"); } } Utility.Utilities.SetCrossPageMessage("Please check your mail", MessageType.Confirmation); Response.Redirect("~/Business/Default.aspx"); }