Example #1
0
        private void SaveUser()
        {
            if (!Page.IsValid)
            {
                return;
            }

            // gather data from form
            UserInfo user = new UserInfo();

            user.UserId   = 0;
            user.Role     = (UserRole)Enum.Parse(typeof(UserRole), role.SelectedValue);
            user.StatusId = Int32.Parse(status.SelectedValue);
            user.OwnerId  = PanelSecurity.SelectedUserId;
            user.IsDemo   = chkDemo.Checked;
            user.IsPeer   = false;

            // account info
            user.FirstName        = txtFirstName.Text;
            user.LastName         = txtLastName.Text;
            user.SubscriberNumber = txtSubscriberNumber.Text;
            user.Email            = txtEmail.Text;
            user.SecondaryEmail   = txtSecondaryEmail.Text;
            user.HtmlMail         = ddlMailFormat.SelectedIndex == 1;
            user.Username         = txtUsername.Text.Trim();
//            user.Password = userPassword.Password;

            // contact info
            user.CompanyName      = contact.CompanyName;
            user.Address          = contact.Address;
            user.City             = contact.City;
            user.Country          = contact.Country;
            user.State            = contact.State;
            user.Zip              = contact.Zip;
            user.PrimaryPhone     = contact.PrimaryPhone;
            user.SecondaryPhone   = contact.SecondaryPhone;
            user.Fax              = contact.Fax;
            user.InstantMessenger = contact.MessengerId;


            // add a new user
            List <string> log = new List <string>();

            try
            {
                //int userId = UsersHelper.AddUser(log, PortalId, user);
                int userId = PortalUtils.AddUserAccount(log, user, chkAccountLetter.Checked, userPassword.Password);

                if (userId == BusinessErrorCodes.ERROR_INVALID_USER_NAME)
                {
                    ShowResultMessage(BusinessErrorCodes.ERROR_INVALID_USER_NAME);
                    return;
                }

                if (userId < 0)
                {
                    ShowResultMessage(userId);
                    return;
                }

                // show log records if any
                if (log.Count > 0)
                {
                    blLog.Items.Clear();
                    foreach (string error in log)
                    {
                        blLog.Items.Add(error);
                    }

                    return;
                }

                // go to user home
                Response.Redirect(PortalUtils.GetUserHomePageUrl(userId));
            }
            catch (Exception ex)
            {
                ShowErrorMessage("USER_ADD_USER", ex);
                return;
            }
        }
Example #2
0
 public string GetUserHomePageUrl(int userId)
 {
     return(PortalUtils.GetUserHomePageUrl(userId));
 }