protected void btncreateaccount_Click(object sender, EventArgs e)
    {
        UserData newUser = new UserData();
        try
        {
            string emailAddress = txtEmail.Text;
            if (!string.IsNullOrEmpty(emailAddress))
            {
                try
                {

                    System.Net.Mail.MailAddress addr = new System.Net.Mail.MailAddress(emailAddress);
                }
                catch
                {
                    litErrorMsg.Text = "Please Enter Valid Email Address.";
                    return;
                }
            }
            UserData userToCreate = new UserData()
            {
                Username = txtUsername.Text,
                Password = txtPassword.Text,
                FirstName = txtFirstName.Text,
                LastName = txtLastname.Text,
                DisplayName = txtUsername.Text,
                Email = txtEmail.Text,
                IsMemberShip = true
            };
            userToCreate.CustomProperties = userManager.GetCustomPropertyList();
            userToCreate.CustomProperties["Phone"].Value = txtPhone.Text;
            userToCreate.CustomProperties["Country"].Value = ddlCountrylist.SelectedValue;
            userToCreate.CustomProperties["Time Zone"].Value = "GMT Standard Time";

            string userSubs = "";

            if (chkHotDeals.Checked)
                userSubs = Resources.ID.SubscriptionHotDealsId;

            if (chkNews.Checked)
                userSubs += "," + Resources.ID.SubscriptionNewsId;
            if (userSubs.StartsWith(","))
                userSubs = userSubs.Remove(0, 1);

            userToCreate.CustomProperties["Subscriptions"].Value = userSubs;

            Ektron.Cms.Framework.User.UserManager umanager = new UserManager();
            newUser = umanager.Add(userToCreate);

            if (newUser.Id != 0)
            {
                divRegistrationwrapper.Visible = false;
                litErrorMsg.Text = "<br /><br />" + Resources.Text.UserCreatedSuccess + "<br /><br />";
            }
            else
            {
                litErrorMsg.Text = Resources.Text.UserCreatedFail;
            }
        }

        catch (Exception ex)
        {
            litErrorMsg.Text = Resources.Text.UserCreatedFail;
        }
    }
Example #2
0
        public static void createSSAEktronMember(string PIN)
        {
            //try
            //{

            Dictionary<string, string> UserDetails = loginSSA.GetUsersDetails(PIN);

            UserManager Usermanager = new UserManager();
            CustomAttributeList attrList = new CustomAttributeList();
            CustomAttribute timeZone = new CustomAttribute();
            timeZone.Name = "Time Zone";
            timeZone.Value = "Eastern Standard Time";
            attrList.Add(timeZone);

            UserData newUserdata = new UserData()
            {
                Username = PIN,
                Password = EktronMemberDefaultPassword,
                FirstName = UserDetails["FirstName"],
                LastName = UserDetails["LastName"],
                DisplayName = UserDetails["DisplayName"],
                Email = UserDetails["Email"],
                CustomProperties = attrList,
                // IsMemberShip = true
            };

            if (Ektron.Cms.Framework.Context.UserContextService.Current.IsLoggedIn)
            {
                Usermanager.Add(newUserdata);
                // add user to group MSBA Members
                UserGroupManager UserGroupmanager = new UserGroupManager();
                //Add a User  to a UserGroup
                UserGroupmanager.AddUser(1, newUserdata.Id);
            }
            //}
            //catch { }
        }