protected void Button1_Click(object sender, EventArgs e)
    {
        if (cboRoles.SelectedValue == "")
        {
            lblErr.Text = "Nao ha mais perfis disponiveis para este usuario";
            lblErr.Visible = true;
        }
        else
        {
            if (userId != 0)
            {
                // Create object
                UsersInRole userInRoles = new UsersInRole();
                userInRoles.UserId = userId;
                userInRoles.RoleId = Convert.ToInt16(cboRoles.SelectedValue);
                userInRoles.CompanyId = Company.CompanyId;

                // Fires Insert
                UsersInRolesManager uManager = new UsersInRolesManager(this);
                uManager.Insert(userInRoles);

                //Refresh the Combo and Grid
                cboRoles.DataBind();
                grdRolesByUser.DataBind();

                // Refresh the menu
                if (User.Identity.UserId == userId)
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ResetMenu", "top.ResetMenu();", true);
            }
        }
    }
예제 #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (cboRoles.SelectedValue == "")
        {
            lblErr.Text    = "Nao ha mais perfis disponiveis para este usuario";
            lblErr.Visible = true;
        }
        else
        {
            if (userId != 0)
            {
                // Create object
                UsersInRole userInRoles = new UsersInRole();
                userInRoles.UserId    = userId;
                userInRoles.RoleId    = Convert.ToInt16(cboRoles.SelectedValue);
                userInRoles.CompanyId = Company.CompanyId;

                // Fires Insert
                UsersInRolesManager uManager = new UsersInRolesManager(this);
                uManager.Insert(userInRoles);

                //Refresh the Combo and Grid
                cboRoles.DataBind();
                grdRolesByUser.DataBind();

                // Refresh the menu
                if (User.Identity.UserId == userId)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ResetMenu", "top.ResetMenu();", true);
                }
            }
        }
    }
예제 #3
0
        public UsersInRolesCollection Get(string usr, int companyID, string getBy)
        {
            switch (getBy)
            {
            case "username":
                return(UsersInRolesManager.GetRolesbyUserName(usr, companyID));

            default:
                return(UsersInRolesManager.GetbyUser(usr, companyID));
            }
        }
        /// <summary>
        /// Method to add a USER in a determined ROLE
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="companyId"></param>
        /// <param name="roleId"></param>
        private void AddUserInRoles(int userId, int companyId, int roleId)
        {
            var newUserInRoles = new UsersInRole();
            var userInRolesManager = new UsersInRolesManager(this);

            newUserInRoles.UserId = userId;
            newUserInRoles.RoleId = roleId;
            newUserInRoles.CompanyId = companyId;
            userInRolesManager.Insert(newUserInRoles);
        }
예제 #5
0
 public void Delete(string userName, int CompanyID, string deleteby)
 {
     UsersInRolesManager.DeleteItemByUsername(userName, CompanyID);
 }
예제 #6
0
 // DELETE api/<controller>/5
 /// <summary>
 /// Deletes the specified identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 public void Delete(String id)
 {
     UsersInRolesManager.DeleteItem(id);
 }
예제 #7
0
 // GET api/<controller>
 /// <summary>
 /// Gets this instance.
 /// </summary>
 /// <returns></returns>
 public UsersInRolesCollection PutSearch(string method, [FromBody] SearchFilter value)
 {
     return(UsersInRolesManager.Search(value));
 }
예제 #8
0
 // PUT api/<controller>/5
 /// <summary>
 /// Puts the specified identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 /// <exception cref="HttpResponseException"></exception>
 public UsersInRoles Put(string id, [FromBody] UsersInRoles value)
 {
     return(UsersInRolesManager.UpdateItem(value));
 }
예제 #9
0
 // POST api/<controller>
 /// <summary>
 /// Posts the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public UsersInRoles Post([FromBody] UsersInRoles value)
 {
     return(UsersInRolesManager.AddItem(value));
 }
예제 #10
0
 // GET api/<controller>/5
 /// <summary>
 /// Gets the specified COM group identifier.
 /// </summary>
 /// <param name="UsersInRolesId">The COM group identifier.</param>
 /// <returns></returns>
 public UsersInRoles Get(String Username, int CompanyID)
 {
     return(UsersInRolesManager.GetItemByID(Username, CompanyID));
 }
예제 #11
0
 public UsersInRolesCollection GetbyUser(string usr, int CompanyID)
 {
     return(UsersInRolesManager.GetbyUser(usr, CompanyID));
 }
예제 #12
0
 // GET api/<controller>
 /// <summary>
 /// Gets this instance.
 /// </summary>
 /// <returns></returns>
 public UsersInRolesCollection Get(int CompanyID)
 {
     return(UsersInRolesManager.GetAllItem(CompanyID));
 }