public static bool Have_Permission(Permissions_Enum permiso) { Get_Conection(); var rol_id = FrontUser.Get_User_Rol(); int val = (int)Enum.Parse(typeof(Permissions_Enum), Enum.GetName(typeof(Permissions_Enum), permiso)); var model = (from permission in connection.SGA_PERMISOS join rp in connection.SGA_ROLES_PERMISOS on permission.ID equals rp.ID_PERMISO where (rp.ID_ROL == rol_id && permission.IDENTIFICADOR == val) || rol_id <= 2 select permission); return(model.Any()); }
public static bool Have_Permission(Permissions_Enum permiso) { if (HttpContext.Current.Session["MENU_PERMISSIONS"] != null) { string list = HttpContext.Current.Session["MENU_PERMISSIONS"].ToString(); var array = list.Split(','); foreach (var i in array) { if (i.Trim() != "") { int value = (int)Enum.Parse(typeof(Permissions_Enum), Enum.GetName(typeof(Permissions_Enum), permiso)); if (value == Convert.ToInt32(i)) { return(true); } } } } return(false); }