Ejemplo n.º 1
0
        //*******************************************************
        //
        // The RolesList_ItemCommand server event handler on this page
        // is used to handle the user editing and deleting roles
        // from the RolesList asp:datalist control
        //
        //*******************************************************
        protected void RolesList_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            int roleId = (int) rolesList.DataKeys[e.Item.ItemIndex];
            IAccountFacade facade = new AccountFacade();

            if (e.CommandName == "edit")
            {
                // Set editable list item index if "edit" button clicked next to the item
                rolesList.EditItemIndex = e.Item.ItemIndex;

                // Repopulate the datalist control
                BindData();
            }
            else if (e.CommandName == "apply")
            {
                // Apply changes
                String _roleName = ((TextBox) e.Item.FindControl("roleName")).Text;

                // update database
                PortalRole role = new PortalRole();
                role.RoleID = roleId;
                role.RoleName = _roleName;
                facade.UpdateRole(role);

                // Disable editable list item access
                rolesList.EditItemIndex = -1;

                // Repopulate the datalist control
                BindData();
            }
            else if (e.CommandName == "delete")
            {
                // update database
                facade.DeleteRole(roleId);

                // Ensure that item is not editable
                rolesList.EditItemIndex = -1;

                // Repopulate list
                BindData();
            }
            else if (e.CommandName == "members")
            {
                // Save role name changes first
                String _roleName = ((TextBox) e.Item.FindControl("roleName")).Text;
                PortalRole role = new PortalRole();
                role.RoleID = roleId;
                role.RoleName = _roleName;
                facade.UpdateRole(role);

                // redirect to edit page
                Response.Redirect("~/Admin/SecurityRoles.aspx?roleId=" + roleId + "&rolename=" + _roleName +
                                  "&tabindex=" + tabIndex + "&tabid=" + tabId);
            }
        }
Ejemplo n.º 2
0
        public void UpdateRoleTest()
        {
            //void UpdateRole(int roleId, String roleName)
            AccountFacade facade = new AccountFacade();

            PortalRole role = new PortalRole();
            role.PortalID = 0;
            role.RoleName = "rl";

            facade.UpdateRole(role);
        }