Example #1
0
        /// <summary>
        /// The SavePageData helper method is used to persist the
        ///   current tab settings to the database.
        /// </summary>
        /// <remarks>
        /// </remarks>
        private void SavePageData()
        {
            // Construct Authorized User Roles string
            var authorizedRoles = string.Empty;

            foreach (ListItem item in this.authRoles.Items)
            {
                if (item.Selected)
                {
                    authorizedRoles = authorizedRoles + item.Text + ";";
                }
            }

            var pageDB = new PagesDB();

            if (!string.IsNullOrEmpty(this.friendlyUrl.Text) && pageDB.IsAlreadyExistsFriendlyUrl(this.friendlyUrl.Text, this.PageID))
            {
                throw new Exception("FriendlyUrlIsAlreadyExists");
            }
            else
            {
                // update Page info in the database
                pageDB.UpdatePage(
                    this.PortalSettings.PortalID,
                    this.PageID,
                    Int32.Parse(this.parentPage.SelectedItem.Value),
                    this.tabName.Text,
                    this.PortalSettings.ActivePage.PageOrder,
                    authorizedRoles,
                    this.mobilePageName.Text,
                    this.showMobile.Checked,
                    this.friendlyUrl.Text);
                List <UserPagePermission> upPerms = new List <UserPagePermission>();
                foreach (GridViewRow gdvRow in gdvUsersAuth.Rows)
                {
                    upPerms.Add(new UserPagePermission()
                    {
                        PageId = this.PageID, UserId = Guid.Parse(((HiddenField)gdvRow.FindControl("hidUserId")).Value), Permission = Convert.ToInt16(((DropDownList)gdvRow.FindControl("ddlUserAuthPermission")).SelectedValue)
                    });
                }
                UserPagePermissionDB uppDB = new UserPagePermissionDB();
                uppDB.UpdatePagePermissions(upPerms, this.PageID);

                // Update custom settings in the database
                this.EditTable.UpdateControls();
            }
        }