BL.Rol.getRolID C# (CSharp) Method

getRolID() public method

public getRolID ( string descripcion ) : long
descripcion string
return long
        public long getRolID(string descripcion)
        {
            try
            {
                var rolID = from r in entidad.roles
                            where r.descripcion == descripcion
                            select r.id;

                return rolID.First();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString() + " --Rol.cs / getRolID()");
            }
        }

Usage Example

    protected void acceptButton_Click(object sender, EventArgs e)
    {
        try
        {
            List<string> revokes = new List<string>();
            //bool flag = false;

            foreach (ListItem it in permisos_CBList.Items)
            {
                if (it.Selected == false)
                {
                    revokes.Add(it.Text);
                    //flag = true;
                }
            }

            List<string> grants = new List<string>();

            foreach (ListItem it in otrosPermisos_CBList.Items)
            {
                if (it.Selected == true)
                {
                    grants.Add(it.Text);
                    //flag = true;
                }
            }

            /*if (flag)
            {*/
                BL.Rol rl = new Rol();
                long rolId = rl.getRolID(descripciones_DDList.SelectedItem.Text);
                AdministradordeSistema admin = new AdministradordeSistema();

                Security sec = new Security();
                long centro = sec.getCentroId(centros.Text);
                admin.editarRol(rolId, descripciones_DDList.SelectedItem.Text, grants, revokes, centro);

                Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Rol Editado')", true);
                setCheckBoxes();
            /*}
            else
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Rol No Editado')", true);
            }*/
        }
        catch (Exception ex)
        {
            Session["Error_Msg"] = ex.Message;
            Response.Redirect("~/Error.aspx", true);
        }
    }
All Usage Examples Of BL.Rol::getRolID