public void AddRoleTest()
        {
            //int AddRole(int portalId, String roleName)
            AccountFacade facade = new AccountFacade();

            PortalRole role = new PortalRole();
            role.PortalID = 0;
            role.RoleName = "role" + DateTime.Now.Ticks;

            facade.AddRole(role);
        }
        public void AddUserRoleTest()
        {
            //void AddUserRole(int roleId, int userId)
            AccountFacade facade = new AccountFacade();
            int UserID = facade.Users()[0].UserID;

            PortalRole role = new PortalRole();
            role.PortalID = 0;
            role.RoleName = "role" + DateTime.Now.Ticks;

            int RoleID = facade.AddRole(role);
            facade.AddUserRole(RoleID, UserID);
        }
        public int AddRole(PortalRole role)
        {
            // TODO: add access security here..
            // TODO: add argument validation here..

            int retval;
            // Run within the context of a database transaction.
            // The Decorator Design Pattern.
            using (TransactionDecorator transaction = new TransactionDecorator())
            {
                retval = rolesDAO.AddRole(role.PortalID, role.RoleName);
                transaction.Complete();
            }
            return retval;
        }
Beispiel #4
0
        //*******************************************************
        //
        // The AddRole_Click server event handler is used to add
        // a new security role for this portal
        //
        //*******************************************************
        protected void AddRole_Click(Object Sender, EventArgs e)
        {
            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings) Context.Items["PortalSettings"];

            // Add a new role to the database
            IAccountFacade facade = new AccountFacade();
            PortalRole role = new PortalRole();
            role.PortalID = portalSettings.PortalId;
            role.RoleName = "�½�ɫ";
            facade.AddRole(role);

            // set the edit item index to the last item
            rolesList.EditItemIndex = rolesList.Items.Count;

            // Rebind list
            BindData();
        }
        public void UpdateRole(PortalRole role)
        {
            // TODO: add access security here..
            // TODO: add argument validation here..

            // Run within the context of a database transaction.
            // The Decorator Design Pattern.
            using (TransactionDecorator transaction = new TransactionDecorator())
            {
                rolesDAO.UpdateRole(role.RoleID, role.RoleName);
                transaction.Complete();
            }
        }
Beispiel #6
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);
            }
        }
        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);
        }