private void SaveUser(bool switchUser)
        {
            // get owner
            UserInfo user = ES.Services.Users.GetUserById(PanelSecurity.LoggedUserId);

            if (Page.IsValid)
            {
                // gather data from form
                // account info
                user.FirstName      = txtFirstName.Text;
                user.LastName       = txtLastName.Text;
                user.Email          = txtEmail.Text;
                user.SecondaryEmail = txtSecondaryEmail.Text;
                user.HtmlMail       = ddlMailFormat.SelectedIndex == 1;

                // 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;

                // update existing user
                try
                {
                    //int result = UsersHelper.UpdateUser(PortalId, user);
                    int result = PortalUtils.UpdateUserAccount(user);

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

                    // set language
                    PortalUtils.SetCurrentLanguage(ddlLanguage.SelectedValue);

                    // set items per page
                    UsersHelper.SetDisplayItemsPerPage(Utils.ParseInt(txtItemsPerPage.Text.Trim(), 10));
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("USER_UPDATE_USER", ex);
                    return;
                }

                // show message
                ShowSuccessMessage("USER_UPDATE_USER");
            }
        }
        private void SaveUser()
        {
            // get owner
            UserInfo owner = PanelSecurity.SelectedUser;

            if (Page.IsValid)
            {
                // gather data from form
                UserInfo user = new UserInfo();
                user.UserId   = PanelRequest.PeerID;
                user.RoleId   = owner.RoleId;
                user.StatusId = owner.StatusId;
                user.OwnerId  = owner.UserId;
                user.IsDemo   = owner.IsDemo;
                user.IsPeer   = true;

                // account info
                user.FirstName      = Server.HtmlEncode(txtFirstName.Text);
                user.LastName       = Server.HtmlEncode(txtLastName.Text);
                user.Email          = txtEmail.Text;
                user.SecondaryEmail = txtSecondaryEmail.Text;
                user.HtmlMail       = ddlMailFormat.SelectedIndex == 1;
                user.Username       = txtUsername.Text;
                user.Password       = userPassword.Password;
                user.IsDemo         = chkDemo.Checked;

                // 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;

                if (PanelRequest.PeerID == 0)
                {
                    // add a new peer
                    List <string> log = new List <string>();

                    try
                    {
                        //int userId = UsersHelper.AddUser(log, PortalId, user);
                        int userId = PortalUtils.AddUserAccount(log, user, false);

                        if (userId < 0)
                        {
                            ShowResultMessage(userId);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        ShowErrorMessage("PEER_ADD_PEER", ex);
                        return;
                    }

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

                        return;
                    }
                }
                else
                {
                    // update existing user
                    try
                    {
                        //int result = UsersHelper.UpdateUser(PortalId, user);
                        int result = PortalUtils.UpdateUserAccount(user);

                        if (result < 0)
                        {
                            ShowResultMessage(result);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        ShowErrorMessage("PEER_UPDATE_PEER", ex);
                        return;
                    }
                }

                // return back to the list
                RedirectBack();
            }
        }
示例#3
0
        private void SaveUser()
        {
            if (Page.IsValid)
            {
                // gather data from form
                UserInfo user = new UserInfo();
                user.UserId = PanelSecurity.SelectedUserId;
                user.Role   = (UserRole)Enum.Parse(typeof(UserRole), role.SelectedValue);
                user.IsDemo = chkDemo.Checked;
                user.Status = ViewState[UserStatusConst] != null ? (UserStatus)ViewState[UserStatusConst]: UserStatus.Active;

                user.LoginStatusId = loginStatus.SelectedIndex;

                // 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;

                // 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;

                // update existing user
                try
                {
                    int result = PortalUtils.UpdateUserAccount(/*TaskID, */ user);

                    //int result = ES.Services.Users.UpdateUserTaskAsynchronously(TaskID, user);
                    AsyncTaskID = TaskID;

                    if (result.Equals(-102))
                    {
                        if (user.RoleId.Equals(3))
                        {
                            ShowResultMessage(result);
                            return;
                        }
                    }
                    else
                    {
                        if (result < 0)
                        {
                            ShowResultMessage(result);
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("USER_UPDATE_USER", ex);
                    return;
                }

                // return back to the list
                RedirectAccountHomePage();
            }
        }